Mercurial > cpython-lru_cache-weakref
diff Lib/http/client.py @ 57802:dc1aadf9fa4a 3.1
Merged revisions 76910 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r76910 | senthil.kumaran | 2009-12-20 12:40:31 +0530 (Sun, 20 Dec 2009) | 10 lines
Merged revisions 76908 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76908 | senthil.kumaran | 2009-12-20 11:35:13 +0530 (Sun, 20 Dec 2009) | 4 lines
Fix for issue 7291 - urllib2 cannot handle https with proxy requiring auth
Refactored HTTPHandler tests and added testcase for proxy authorization.
........
................
| author | Senthil Kumaran <orsenthil@gmail.com> |
|---|---|
| date | Sun, 20 Dec 2009 07:18:22 +0000 |
| parents | a17cd9fcdd46 |
| children | 6950eab51ffe |
line wrap: on
line diff
--- a/Lib/http/client.py Sat Dec 19 23:33:46 2009 +0000 +++ b/Lib/http/client.py Sun Dec 20 07:18:22 2009 +0000 @@ -648,9 +648,13 @@ if strict is not None: self.strict = strict - def _set_tunnel(self, host, port=None): + def _set_tunnel(self, host, port=None, headers=None): self._tunnel_host = host self._tunnel_port = port + if headers: + self._tunnel_headers = headers + else: + self._tunnel_headers.clear() def _set_hostport(self, host, port): if port is None: @@ -674,12 +678,18 @@ def _tunnel(self): self._set_hostport(self._tunnel_host, self._tunnel_port) - connect_str = "CONNECT %s:%d HTTP/1.0\r\n\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(): + header_str = "%s: %s\r\n" % (header, value) + header_bytes = header_str.encode("ascii") + self.send(header_bytes) + response = self.response_class(self.sock, strict = self.strict, - method= self._method) + method = self._method) (version, code, message) = response._read_status() + if code != 200: self.close() raise socket.error("Tunnel connection failed: %d %s" % (code,
