summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_httplib.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium>2015-09-07 01:18:47 (GMT)
committerMartin Panter <vadmium>2015-09-07 01:18:47 (GMT)
commitb75a0e9f32c47cc75924c79f7ac74e2f11f32506 (patch)
tree4909ada1dc7f4d3bbfd86da06a064b32c93bd6ec /Lib/test/test_httplib.py
parent04861dc82f595e3e2f0ab4b1a62de2f812c8fa37 (diff)
downloadcpython-b75a0e9f32c47cc75924c79f7ac74e2f11f32506.zip
cpython-b75a0e9f32c47cc75924c79f7ac74e2f11f32506.tar.gz
cpython-b75a0e9f32c47cc75924c79f7ac74e2f11f32506.tar.bz2
Issue #17849: Raise sensible exception for invalid HTTP tunnel response
Initial patch from Cory Benfield.
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r--Lib/test/test_httplib.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 3014589..a72f6f7 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -578,6 +578,16 @@ class BasicTest(TestCase):
#self.assertTrue(response[0].closed)
self.assertTrue(conn.sock.file_closed)
+ def test_proxy_tunnel_without_status_line(self):
+ # Issue 17849: If a proxy tunnel is created that does not return
+ # a status code, fail.
+ body = 'hello world'
+ conn = httplib.HTTPConnection('example.com', strict=False)
+ conn.set_tunnel('foo')
+ conn.sock = FakeSocket(body)
+ with self.assertRaisesRegexp(socket.error, "Invalid response"):
+ conn._tunnel()
+
class OfflineTest(TestCase):
def test_responses(self):
self.assertEqual(httplib.responses[httplib.NOT_FOUND], "Not Found")