1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #30015 -- Ensured request body is properly consumed for keep-alive connections.

This commit is contained in:
Konstantin Alekseev
2018-12-06 18:08:01 +03:00
committed by Carlton Gibson
parent 1939dd49d1
commit b514dc14f4
4 changed files with 43 additions and 0 deletions

View File

@@ -111,6 +111,23 @@ class LiveServerViews(LiveServerBase):
finally:
conn.close()
def test_keep_alive_connection_clears_previous_request_data(self):
conn = HTTPConnection(LiveServerViews.server_thread.host, LiveServerViews.server_thread.port)
try:
conn.request('POST', '/method_view/', b'{}', headers={"Connection": "keep-alive"})
response = conn.getresponse()
self.assertFalse(response.will_close)
self.assertEqual(response.status, 200)
self.assertEqual(response.read(), b'POST')
conn.request('POST', '/method_view/', b'{}', headers={"Connection": "close"})
response = conn.getresponse()
self.assertFalse(response.will_close)
self.assertEqual(response.status, 200)
self.assertEqual(response.read(), b'POST')
finally:
conn.close()
def test_404(self):
with self.assertRaises(HTTPError) as err:
self.urlopen('/')