fix(app): respect autocorrect_location_header in make_response
This commit is contained in:
parent
e5fd6e11e4
commit
9016ca3fd0
2 changed files with 20 additions and 1 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
Version 3.1.2
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Unreleased
|
||||||
|
|
||||||
|
- Respect ``autocorrect_location_header`` in ``make_response``. :issue:`5774`
|
||||||
|
|
||||||
Version 3.1.1
|
Version 3.1.1
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1262,8 +1262,20 @@ class Flask(App):
|
||||||
else:
|
else:
|
||||||
rv.status_code = status
|
rv.status_code = status
|
||||||
|
|
||||||
# extend existing headers with provided headers
|
|
||||||
if headers:
|
if headers:
|
||||||
|
headers = Headers(headers)
|
||||||
|
# Pop the Location header to handle it separately.
|
||||||
|
# This handles both "Location" and "location" keys.
|
||||||
|
location = headers.pop("Location", None) or headers.pop("location", None)
|
||||||
|
|
||||||
|
# If a Location header was found, set it using the response
|
||||||
|
# .location property. This respects the 'autocorrect_location_header'
|
||||||
|
# flag, which is the purpose of this fix.
|
||||||
|
|
||||||
|
if location is not None:
|
||||||
|
rv.location = location
|
||||||
|
|
||||||
|
# Add the remaining headers to the response.
|
||||||
rv.headers.update(headers)
|
rv.headers.update(headers)
|
||||||
|
|
||||||
return rv
|
return rv
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue