Flask and Transfer-Encoding: chunked
Its not the Flask Python, its the mod_wsgi. Only mod_wsgi versions 3.0+ started to support chunked http transfers. Flask Python internally use Werkzeug tool-kit as an interface to mod_wsgi. If you installed it from the apt sources it may be an old version.
Try compiling the latest version of mod_wsgi and then install the Flask framework, it may solve the problem.
This works for me but its not the most elegant way of shimming chunked parsing. I used the method of sticking the body into the environment of the response.
Get raw POST body in Python Flask regardless of Content-Type header
But added code to deal with chunked parsing
class WSGICopyBody(object): def __init__(self, application): self.application = application def __call__(self, environ, start_response): from cStringIO import StringIO input = environ.get('wsgi.input') length = environ.get('CONTENT_LENGTH', '0') length = 0 if length == '' else int(length) body = '' if length == 0: environ['body_copy'] = '' if input is None: return if environ.get('HTTP_TRANSFER_ENCODING','0') == 'chunked': size = int(input.readline(),16) while size > 0: body += input.read(size+2) size = int(input.readline(),16) else: body = environ['wsgi.input'].read(length) environ['body_copy'] = body environ['wsgi.input'] = StringIO(body) # Call the wrapped application app_iter = self.application(environ, self._sr_callback(start_response)) # Return modified response return app_iter def _sr_callback(self, start_response): def callback(status, headers, exc_info=None): # Call upstream start_response start_response(status, headers, exc_info) return callbackapp.wsgi_app = WSGICopyBody(app.wsgi_app)
use this to get at it
request.environ['body_copy']