mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
#10983: fix several bugs in the _tunnel implementation that seem to have missed while porting between branches. A unittest is needed!
This commit is contained in:
parent
59531287fd
commit
c7c199f907
2 changed files with 7 additions and 3 deletions
|
@ -653,6 +653,7 @@ class HTTPConnection:
|
|||
self._method = None
|
||||
self._tunnel_host = None
|
||||
self._tunnel_port = None
|
||||
self._tunnel_headers = {}
|
||||
|
||||
self._set_hostport(host, port)
|
||||
|
||||
|
@ -691,15 +692,16 @@ class HTTPConnection:
|
|||
|
||||
def _tunnel(self):
|
||||
self._set_hostport(self._tunnel_host, self._tunnel_port)
|
||||
connect_str = "CONNECT %s:%d HTTP/1.0\r\n" %(self.host, self.port)
|
||||
connect_str = "CONNECT %s:%d HTTP/1.0\r\n" % (self.host, self.port)
|
||||
connect_bytes = connect_str.encode("ascii")
|
||||
self.send(connect_bytes)
|
||||
for header, value in self._tunnel_headers.iteritems():
|
||||
for header, value in self._tunnel_headers.items():
|
||||
header_str = "%s: %s\r\n" % (header, value)
|
||||
header_bytes = header_str.encode("latin1")
|
||||
self.send(header_bytes)
|
||||
self.send(b'\r\n')
|
||||
|
||||
response = self.response_class(self.sock, method = self._method)
|
||||
response = self.response_class(self.sock, method=self._method)
|
||||
(version, code, message) = response._read_status()
|
||||
|
||||
if code != 200:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue