mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
Fix handling of Chunked requests (#1742)
* 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
This commit is contained in:
committed by
Maxime Beauchemin
parent
0d2c2b0681
commit
274d21795f
@@ -80,6 +80,20 @@ if app.config.get('ENABLE_CORS'):
|
||||
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'))
|
||||
|
||||
Reference in New Issue
Block a user