chunked encoding

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2017-08-04 19:40:45 -04:00
parent 6f6b824745
commit 2e94212886
+15
View File
@@ -42,12 +42,23 @@ ENV_COOKIES = (
'__utmb'
)
def jsonify(*args, **kwargs):
response = flask_jsonify(*args, **kwargs)
if not response.data.endswith(b'\n'):
response.data += b'\n'
return response
class InputTerminated:
def __init__(self, wsgi_app):
self.wsgi_app = wsgi_app
def __call__(self, environ, start_response):
environ['wsgi.input_terminated'] = True
return self.wsgi_app(environ, start_response)
# Prevent WSGI from correcting the casing of the Location header
BaseResponse.autocorrect_location_header = False
@@ -57,6 +68,10 @@ tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
app = Flask(__name__, template_folder=tmpl_dir)
app.debug = bool(os.environ.get('DEBUG'))
# Support for chunked-encoding.
app.wsgi_app = InputTerminated(app.wsgi_app)
# Setup Flask-Common.
common = Common(app)