Skip to content

Commit

Permalink
Fix handling of Chunked requests (apache#1742)
Browse files Browse the repository at this point in the history
* Fix handling of Chunked requests

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

* remove debug print logging
  • Loading branch information
nishantmonu51 authored and Grace Guo committed Jun 13, 2017
1 parent 280a55c commit 59e3027
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions superset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@
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.
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 59e3027

Please sign in to comment.