Search code examples
ruby-on-railsunicornthinpuma

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


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?)


Solution

  • 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