|
|
0e4a7e2 |
From 06f390d522afb6d2d71bb601c2060a9fabe3f7de Mon Sep 17 00:00:00 2001
|
|
|
3eec711 |
From: Adam Williamson <awilliam@redhat.com>
|
|
|
3eec711 |
Date: Mon, 19 Jul 2021 15:41:23 -0700
|
|
|
3eec711 |
Subject: [PATCH] Fix disabling of location header autocorrect for werkzeug 2+
|
|
|
b0b790c |
(#647)
|
|
|
3eec711 |
|
|
|
3eec711 |
In werkzeug 2.0.0 and later, the Location header autocorrection
|
|
|
3eec711 |
moved from BaseResponse to Response, so we need to set
|
|
|
3eec711 |
`autocorrect_location_header = False` in `Response` not
|
|
|
b0b790c |
`BaseResponse`. From 2.1.0, BaseResponse is removed and importing
|
|
|
b0b790c |
it is an error, so we can't support both any more.
|
|
|
3eec711 |
|
|
|
3eec711 |
Signed-off-by: Adam Williamson <awilliam@redhat.com>
|
|
|
3eec711 |
---
|
|
|
b0b790c |
httpbin/core.py | 6 ++++--
|
|
|
b0b790c |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
3eec711 |
|
|
|
3eec711 |
diff --git a/httpbin/core.py b/httpbin/core.py
|
|
|
0e4a7e2 |
index 66a2ed6..fd2842c 100644
|
|
|
3eec711 |
--- a/httpbin/core.py
|
|
|
3eec711 |
+++ b/httpbin/core.py
|
|
|
0e4a7e2 |
@@ -19,7 +19,7 @@ from flask import Flask, Response, request, render_template, redirect, jsonify a
|
|
|
b0b790c |
from six.moves import range as xrange
|
|
|
b0b790c |
from werkzeug.datastructures import WWWAuthenticate, MultiDict
|
|
|
b0b790c |
from werkzeug.http import http_date
|
|
|
b0b790c |
-from werkzeug.wrappers import BaseResponse
|
|
|
b0b790c |
+from werkzeug.wrappers import Response as WzResponse
|
|
|
b0b790c |
from werkzeug.http import parse_authorization_header
|
|
|
0e4a7e2 |
from raven.contrib.flask import Sentry
|
|
|
b0b790c |
|
|
|
0e4a7e2 |
@@ -48,7 +48,9 @@ def jsonify(*args, **kwargs):
|
|
|
0e4a7e2 |
return response
|
|
|
3eec711 |
|
|
|
3eec711 |
# Prevent WSGI from correcting the casing of the Location header
|
|
|
b0b790c |
-BaseResponse.autocorrect_location_header = False
|
|
|
b0b790c |
+# and forcing it to be absolute.
|
|
|
b0b790c |
+WzResponse.autocorrect_location_header = False
|
|
|
b0b790c |
+
|
|
|
3eec711 |
|
|
|
3eec711 |
# Find the correct template folder when running from a different location
|
|
|
0e4a7e2 |
tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
|
|
|
3eec711 |
--
|
|
|
b0b790c |
2.36.0
|
|
|
3eec711 |
|