Skip to content

Commit 496d0b9

Browse files
committed
Fix compatibility with werkzeug 2.1.x
Update the code for werkzeug 2.1.x where `BaseResponse` class was replaced by `Response`. See: pallets/werkzeug#2276 Taken from postmanlabs#684
1 parent cefb0c4 commit 496d0b9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

httpbin/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
)
2929
from werkzeug.datastructures import WWWAuthenticate, MultiDict
3030
from werkzeug.http import http_date
31-
from werkzeug.wrappers import BaseResponse
31+
try:
32+
from werkzeug.wrappers import Response
33+
except ImportError: # werkzeug < 2.1
34+
from werkzeug.wrappers import BaseResponse as Response
3235
from werkzeug.http import parse_authorization_header
3336
from flasgger import Swagger, NO_SANITIZER
3437

@@ -76,7 +79,7 @@ def jsonify(*args, **kwargs):
7679

7780

7881
# Prevent WSGI from correcting the casing of the Location header
79-
BaseResponse.autocorrect_location_header = False
82+
Response.autocorrect_location_header = False
8083

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

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
packages=find_packages(),
3636
include_package_data = True, # include files listed in MANIFEST.in
3737
install_requires=[
38-
'Flask<2', 'MarkupSafe<2.1', 'decorator', 'itsdangerous<2.1', 'brotlipy',
39-
'raven[flask]', 'werkzeug<2', 'gevent', 'flasgger', 'jinja2<3.1'
38+
'Flask<2.3', 'MarkupSafe', 'decorator', 'itsdangerous', 'brotlipy',
39+
'raven[flask]', 'werkzeug<2.3', 'gevent', 'flasgger', 'jinja2'
4040
],
4141
)

0 commit comments

Comments
 (0)