From ccd417eea8d13192ea980539e1a4bbe31206c802 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Mon, 19 Jul 2021 15:41:23 -0700 Subject: [PATCH] Fix disabling of location header autocorrect for werkzeug 2+ (#647) 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 --- httpbin/core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/httpbin/core.py b/httpbin/core.py index 305c9882..3726e21f 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -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")