Roosh Roosh - 1 year ago 147
Python Question

How to set gunicorn limit_request_line parameter over 8190?

I need to post large text fragment to web-application beside gunicorn.
But gunicorn failed requests that large 8190 request line.

This constant hardcoded this

And used this line:

How can redefine behavior?

Answer Source

If you set the value to zero, Gunicorn treats it as unlimited. From the docs:


  • --limit-request-line INT
  • 4094

The maximum size of HTTP request line in bytes.

This parameter is used to limit the allowed size of a client's HTTP request-line. Since the request-line consists of the HTTP method, URI, and protocol version, this directive places a restriction on the length of a request-URI allowed for a request on the server. A server needs this value to be large enough to hold any of its resource names, including any information that might be passed in the query part of a GET request. Value is a number from 0 (unlimited) to 8190.

This parameter can be used to prevent any DDOS attack.

If you need to set it to some value higher than 8190, you'll have to change the source code or build a simple wrapper around Gunicorn's main script that patches the value (although since this uses an internal API, you risk breaking things when upgrading):


from gunicorn.http import message
message.MAX_REQUEST_LINE = 2**16 - 2

from import run
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download