Skip to content

Commit

Permalink
Fix disabling of location header autocorrect for werkzeug 2+
Browse files Browse the repository at this point in the history
In werkzeug 2.0.0 and later, the Location header autocorrection
moved from BaseResponse to Response, so we need to set
`autocorrect_location_header = False` in `Response` not
`BaseResponse`. For now let's just set it in both to be safe,
this doesn't cause any errors at least with 1.0.1 and 2.0.1.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
  • Loading branch information
AdamWill committed Jul 19, 2021
1 parent 992eaa4 commit c5f411d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions httpbin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def jsonify(*args, **kwargs):


# Prevent WSGI from correcting the casing of the Location header
# and forcing it to be absolute. This moved from BaseResponse to
# Response in werkzeug 2.0.0, so we set both to be safe.
BaseResponse.autocorrect_location_header = False
Response.autocorrect_location_header = False

# Find the correct template folder when running from a different location
tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates")
Expand Down

0 comments on commit c5f411d

Please sign in to comment.