Skip to content

Commit

Permalink
chunked encoding
Browse files Browse the repository at this point in the history
Signed-off-by: Kenneth Reitz <[email protected]>
  • Loading branch information
kennethreitz committed Aug 4, 2017
1 parent 6f6b824 commit 2e94212
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions httpbin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,23 @@
'__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

Expand All @@ -57,6 +68,10 @@ def jsonify(*args, **kwargs):
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)

Expand Down

0 comments on commit 2e94212

Please sign in to comment.