Issue #22095: Fixed HTTPConnection.set_tunnel with default port. The port

value in the host header was set to "None".  Patch by Demian Brecht.
This commit is contained in:
Serhiy Storchaka 2014-12-12 09:29:15 +02:00
parent 1e40f10886
commit 4ac7ed97a8
3 changed files with 11 additions and 8 deletions

View file

@ -771,8 +771,7 @@ class HTTPConnection:
if self.sock:
raise RuntimeError("Can't set up tunnel for established connection")
self._tunnel_host = host
self._tunnel_port = port
self._tunnel_host, self._tunnel_port = self._get_hostport(host, port)
if headers:
self._tunnel_headers = headers
else:
@ -802,9 +801,8 @@ class HTTPConnection:
self.debuglevel = level
def _tunnel(self):
(host, port) = self._get_hostport(self._tunnel_host,
self._tunnel_port)
connect_str = "CONNECT %s:%d HTTP/1.0\r\n" % (host, port)
connect_str = "CONNECT %s:%d HTTP/1.0\r\n" % (self._tunnel_host,
self._tunnel_port)
connect_bytes = connect_str.encode("ascii")
self.send(connect_bytes)
for header, value in self._tunnel_headers.items():