Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/Servers/GunicornServer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [body]

start_response('200 OK', [('Content-Type', 'text/plain')])
if environ['REQUEST_METHOD'] == 'POST':
try:
length = int(environ.get('CONTENT_LENGTH', 0) or 0)
except ValueError:
length = 0
body = environ['wsgi.input'].read(length) if length > 0 else b''
if environ.get('HTTP_TRANSFER_ENCODING'):
# chunked request: no Content-Length; Gunicorn's worker dechunks, so read to EOF
try:
body = environ['wsgi.input'].read()
except Exception:
start_response('400 Bad Request', [('Content-Type', 'text/plain')])
return [b'']
else:
try:
length = int(environ.get('CONTENT_LENGTH', 0) or 0)
except ValueError:
length = 0
body = environ['wsgi.input'].read(length) if length > 0 else b''
start_response('200 OK', [('Content-Type', 'text/plain')])
return [body]
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b'OK']
Loading