Mercurial > public > mercurial-scm > hg-stable
diff mercurial/httpclient/tests/simple_http_test.py @ 15218:c81dce8a7bb6
httpclient: update to 07d8c356f4d1 of py-nonblocking-http
This addresses a defect when the server closes the socket before
finishing a response (if it crashes, for example) first spotted in
Issue2951.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 10 Oct 2011 17:57:40 -0500 |
parents | a75e0f4ba0ab |
children | 24dbef11f477 |
line wrap: on
line diff
--- a/mercurial/httpclient/tests/simple_http_test.py Mon Oct 10 13:52:54 2011 +0200 +++ b/mercurial/httpclient/tests/simple_http_test.py Mon Oct 10 17:57:40 2011 -0500 @@ -380,6 +380,21 @@ con.request('GET', '/') self.assertEqual(2, len(sockets)) + def test_server_closes_before_end_of_body(self): + con = http.HTTPConnection('1.2.3.4:80') + con._connect() + s = con.sock + s.data = ['HTTP/1.1 200 OK\r\n', + 'Server: BogusServer 1.0\r\n', + 'Connection: Keep-Alive\r\n', + 'Content-Length: 16', + '\r\n\r\n', + 'You can '] # Note: this is shorter than content-length + s.close_on_empty = True + con.request('GET', '/') + r1 = con.getresponse() + self.assertRaises(http.HTTPRemoteClosedError, r1.read) + def test_no_response_raises_response_not_ready(self): con = http.HTTPConnection('foo') self.assertRaises(http.httplib.ResponseNotReady, con.getresponse)