mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 06:46:16 +00:00
Added support for chunked encoded requests when running gunicorn. Fixed #340.
In this commit: - when we see a Transfer-Encoding: chunked request, and the server is gunicorn, we set environ wsgi.input_terminated, which is required by Werkzeug in the absence of Content-Lenght, or it will empty the data stream. - for chunked requests to non-gunicorn, return 501 Not Implemented.
This commit is contained in:
@@ -206,6 +206,25 @@ class HttpbinTestCase(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
"""
|
||||
This is currently a sort of negative-test.
|
||||
We validate that when running Flask-only server that
|
||||
Transfer-Encoding: chunked requests are unsupported and
|
||||
we return 501 Not Implemented
|
||||
"""
|
||||
def test_post_chunked(self):
|
||||
data = '{"animal":"dog"}'
|
||||
response = self.app.post(
|
||||
'/post',
|
||||
content_type='application/json',
|
||||
headers=[('Transfer-Encoding', 'chunked')],
|
||||
data=data,
|
||||
)
|
||||
self.assertEqual(response.status_code, 501)
|
||||
#self.assertEqual(response.status_code, 200)
|
||||
#self.assertEqual(json.loads(response.data.decode('utf-8'))['data'], '{"animal":"dog"}')
|
||||
#self.assertEqual(json.loads(response.data.decode('utf-8'))['json'], {"animal": "dog"})
|
||||
|
||||
def test_set_cors_headers_after_request(self):
|
||||
response = self.app.get('/get')
|
||||
self.assertEqual(
|
||||
|
||||
Reference in New Issue
Block a user