Thin server QUERY_STRING is longer than the (1024 * 10) allowed length

帅比萌擦擦* 提交于 2020-01-04 05:25:25

问题


How can I increase the maximum allowed value for QUERY_STRING using either thin, puma, or unicorn web servers in Rails? I'm attempting to make a POST request to my Rails API that exceeds the limit, and just need to increase the server's maximum threshold

Specific error on POST: Invalid request: HTTP element QUERY_STRING is longer than the (1024 * 10) allowed length.

I only came across this question in one other place (HTTP query string length with thin web server) and I couldn't quite make sense of the answer (specifically, where does one find the C file to edit in that answer?)


回答1:


You'll find thin.c in something like ~/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/ext/thin_parser

you'll want to change

DEF_MAX_LENGTH(REQUEST_URI, 1024 * 12); 
...
DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10));

in this same folder you just need to use the Makefile to reload the thin_parser.so, and to replace the previous thin_parser.so by the new one in ~/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/lib (seems like the Makefile is not doing it itself)

make clean && make && cp thin_parser.so ../../lib/

I just made it work that way, hope it helps




回答2:


The file in question is in /ext/thin_parser/thin.c within the gem source code. To make the change you want I believe the easiest path would be to fork this gem on Github, publish your changes in your fork, and then bundle your version using the git: option in your Gemfile. Like:

gem 'thin', git: '<URL to your fork>', branch: '<branch of fork to use>'


来源:https://stackoverflow.com/questions/33132649/thin-server-query-string-is-longer-than-the-1024-10-allowed-length

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!