Skip to content

Commit c3ad946

Browse files
committed
fix Werkzeug 2.1.x compatibility
- fix httpbin/core.py: use Responce class instead of BaseResponse see: pallets/werkzeug#2276 - fix tests: TestClient doesn't provide 'Content-Length' header anymore see: pallets/werkzeug#2347
1 parent f8ec666 commit c3ad946

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

httpbin/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from six.moves import range as xrange
3030
from werkzeug.datastructures import WWWAuthenticate, MultiDict
3131
from werkzeug.http import http_date
32-
from werkzeug.wrappers import BaseResponse
32+
from werkzeug.wrappers import Response
3333
from werkzeug.http import parse_authorization_header
3434
from flasgger import Swagger, NO_SANITIZER
3535

@@ -77,7 +77,7 @@ def jsonify(*args, **kwargs):
7777

7878

7979
# Prevent WSGI from correcting the casing of the Location header
80-
BaseResponse.autocorrect_location_header = False
80+
Response.autocorrect_location_header = False
8181

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

test_httpbin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_get(self):
148148
data = json.loads(response.data.decode('utf-8'))
149149
self.assertEqual(data['args'], {})
150150
self.assertEqual(data['headers']['Host'], 'localhost')
151-
self.assertEqual(data['headers']['Content-Length'], '0')
151+
# self.assertEqual(data['headers']['Content-Length'], '0')
152152
self.assertEqual(data['headers']['User-Agent'], 'test')
153153
# self.assertEqual(data['origin'], None)
154154
self.assertEqual(data['url'], 'http://localhost/get')
@@ -162,7 +162,7 @@ def test_anything(self):
162162
data = json.loads(response.data.decode('utf-8'))
163163
self.assertEqual(data['args'], {})
164164
self.assertEqual(data['headers']['Host'], 'localhost')
165-
self.assertEqual(data['headers']['Content-Length'], '0')
165+
# self.assertEqual(data['headers']['Content-Length'], '0')
166166
self.assertEqual(data['url'], 'http://localhost/anything/foo/bar')
167167
self.assertEqual(data['method'], 'GET')
168168
self.assertTrue(response.data.endswith(b'\n'))

0 commit comments

Comments
 (0)