Skip to content

Commit

Permalink
Resolves ISSUE #5
Browse files Browse the repository at this point in the history
Added new method to index.py to fix an issue with chunked
encoding and missing request bodies

Signed-off-by: Stephen Sullivan <[email protected]>
  • Loading branch information
ssullivan authored and alexellis committed Nov 3, 2018
1 parent 366e37d commit a64bdac
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions template/python27-flask/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

app = Flask(__name__)

@app.before_request
def fix_transfer_encoding():
"""
Sets the "wsgi.input_terminated" environment flag, thus enabling
Werkzeug to pass chunked requests as streams. The gunicorn server
should set this, but it's not yet been implemented.
"""

transfer_encoding = request.headers.get("Transfer-Encoding", None)
if transfer_encoding == u"chunked":
request.environ["wsgi.input_terminated"] = True

@app.route("/", defaults={"path": ""}, methods=["POST", "GET"])
@app.route("/<path:path>", methods=["POST", "GET"])
def main_route(path):
Expand Down
12 changes: 12 additions & 0 deletions template/python3-flask-armhf/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

app = Flask(__name__)

@app.before_request
def fix_transfer_encoding():
"""
Sets the "wsgi.input_terminated" environment flag, thus enabling
Werkzeug to pass chunked requests as streams. The gunicorn server
should set this, but it's not yet been implemented.
"""

transfer_encoding = request.headers.get("Transfer-Encoding", None)
if transfer_encoding == u"chunked":
request.environ["wsgi.input_terminated"] = True

@app.route("/", defaults={"path": ""}, methods=["POST", "GET"])
@app.route("/<path:path>", methods=["POST", "GET"])
def main_route(path):
Expand Down
12 changes: 12 additions & 0 deletions template/python3-flask/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

app = Flask(__name__)

@app.before_request
def fix_transfer_encoding():
"""
Sets the "wsgi.input_terminated" environment flag, thus enabling
Werkzeug to pass chunked requests as streams. The gunicorn server
should set this, but it's not yet been implemented.
"""

transfer_encoding = request.headers.get("Transfer-Encoding", None)
if transfer_encoding == u"chunked":
request.environ["wsgi.input_terminated"] = True

@app.route("/", defaults={"path": ""}, methods=["POST", "GET"])
@app.route("/<path:path>", methods=["POST", "GET"])
def main_route(path):
Expand Down

0 comments on commit a64bdac

Please sign in to comment.