Also simplifies the environment handling in the gevent_pywsgi
server so that it also has this key. An added side effect is
that the gunicorn FileWrapper gets set for the gevent_pywsgi
worker, too.
Fixes#486
By if the options ` --error-logfile` is set to '-' then wsgi.errors are
returned to sys.stderr, if any log file is passed either using the
log-config file or the option, Errors are written to the files.
By default no error is returned.
Gunicorn shouln't override the SERVER_* by the Host header. The client
will take care about it during the URL reconstruction if needed.
Since the spec don't support unix sockets, Gunicorn is using the HOST
heeader when available to create viable SERVER_* if possible so the
application and framworks will be happy. When the Host Header is not
available (SocketPath, '') is returned.
fix#628
The remote address should return the direct client addr not a forwarded
header.
This is a breaking change. The main problem with such changes is the way
the application or framework will handle the URL completion. Indeed most
of them are only expecting a TCP socket.
fix#633
Get the status code from the response once so we can use it to check the need
for the connection header later without parsing the string each time we need it.
This patch makes sure that we now handle correctly bytes and native
strings on python 3:
- In python 3, sockets are now taking and returning bytes.
- according to PEP3333, headers should be native strings and body in
bytes.
If remote client send invalid data in request with "Transfer-Encoding:chunked" gunicorn can raised some exceptions (see http.body.ChunkedReader) as NoMoreData, ChunkMissingTerminator, InvalidChunkSize.
User application shouldn't know about specific gunicorn exceptions and must catch standard IOError if want.
Example:
def app(env, start_response):
body = env["wsgi.input"]
chunk_size = 1024
while True:
try:
chunk = body.read(chunk_size)
except IOError:
.. correct action for error
if not chunk:
break
.. do somethink with chunk
We were accidentally including partial data when we didn't find the
request line terminating '\r\n'. This changes the check to make sure
we're testing the length after we assert there's no termination.
patch from Djoume Salvetti . address the following issues in gunicorn:
* Gunicorn does not limit the size of a request header (the
* limit_request_field_size configuration parameter is not used)
* When the configured request limit is lower than its maximum value, the
* maximum value is used instead. For instance if limit_request_line is
* set to 1024, gunicorn will only limit the request line to 4096 chars
* (this issue also affects limit_request_fields)
* Request limits are not limited to their maximum authorized values. For
* instance it is possible to set limit_request_line to 64K (this issue
* also affects limit_request_fields)
* Setting limit_request_fields and limit_request_field_size to 0 does
* not make them unlimited. The following patch allows limit_request_line
* and limit_request_field_size to be unlimited. limit_request_fields can
* no longer be unlimited (I can't imagine 32K fields to not be enough
* but I have a use case where 8K for the request line is not enough).
* Parsing errors (premature client disconnection) are not reported
* When request line limit is exceeded the configured value is reported
* instead of the effective value.