Skip to content

Commit

Permalink
Fix handling of Chunked requests
Browse files Browse the repository at this point in the history
Add fix for handling chunk encoding requests.
If ENABLE_CHUNK_ENCODING is set to true, for requests with transfer
encoding set to true. It will set wsgi.input_terminated to true which
tells werkzeug to ignore content-length and read the stream till the
end.

 break comment in multiple lines
  • Loading branch information
nishantmonu51 committed Dec 2, 2016
1 parent 324205f commit fff280b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions superset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@
if app.config.get('ENABLE_PROXY_FIX'):
app.wsgi_app = ProxyFix(app.wsgi_app)

if app.config.get('ENABLE_CHUNK_ENCODING'):
class ChunkedEncodingFix(object):

def __init__(self, app):
self.app = app

def __call__(self, environ, start_response):
# Setting wsgi.input_terminated tells werkzeug.wsgi to ignore
# content-length and read the stream till the end.
print(environ)
if 'chunked' == environ.get('HTTP_TRANSFER_ENCODING', '').lower():
environ['wsgi.input_terminated'] = True
return self.app(environ, start_response)
app.wsgi_app = ChunkedEncodingFix(app.wsgi_app)

if app.config.get('UPLOAD_FOLDER'):
try:
os.makedirs(app.config.get('UPLOAD_FOLDER'))
Expand Down

0 comments on commit fff280b

Please sign in to comment.