diff options
author | Martin Panter <vadmium> | 2015-09-07 01:18:47 (GMT) |
---|---|---|
committer | Martin Panter <vadmium> | 2015-09-07 01:18:47 (GMT) |
commit | b75a0e9f32c47cc75924c79f7ac74e2f11f32506 (patch) | |
tree | 4909ada1dc7f4d3bbfd86da06a064b32c93bd6ec /Lib/httplib.py | |
parent | 04861dc82f595e3e2f0ab4b1a62de2f812c8fa37 (diff) | |
download | cpython-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/httplib.py')
-rw-r--r-- | Lib/httplib.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index fc908d2..7223ba1 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -810,6 +810,11 @@ class HTTPConnection: method = self._method) (version, code, message) = response._read_status() + if version == "HTTP/0.9": + # HTTP/0.9 doesn't support the CONNECT verb, so if httplib has + # concluded HTTP/0.9 is being used something has gone wrong. + self.close() + raise socket.error("Invalid response from tunnel request") if code != 200: self.close() raise socket.error("Tunnel connection failed: %d %s" % (code, |