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:
Brett Randall
2017-11-27 07:13:46 +11:00
parent 260ee9b431
commit 9e9cb84724
2 changed files with 44 additions and 1 deletions
+19
View File
@@ -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(