MCPcopy Index your code
hub / github.com/python/cpython / _tunnel

Method _tunnel

Lib/http/client.py:978–1008  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

976 return ip
977
978 def _tunnel(self):
979 connect = b"CONNECT %s:%d %s\r\n" % (
980 self._wrap_ipv6(self._tunnel_host.encode("idna")),
981 self._tunnel_port,
982 self._http_vsn_str.encode("ascii"))
983 headers = [connect]
984 for header, value in self._tunnel_headers.items():
985 headers.append(f"{header}: {value}\r\n".encode("latin-1"))
986 headers.append(b"\r\n")
987 # Making a single send() call instead of one per line encourages
988 # the host OS to use a more optimal packet size instead of
989 # potentially emitting a series of small packets.
990 self.send(b"".join(headers))
991 del headers
992
993 response = self.response_class(self.sock, method=self._method)
994 try:
995 (version, code, message) = response._read_status()
996
997 self._raw_proxy_headers = _read_headers(response.fp, self.max_response_headers)
998
999 if self.debuglevel > 0:
1000 for header in self._raw_proxy_headers:
1001 print('header:', header.decode())
1002
1003 if code != http.HTTPStatus.OK:
1004 self.close()
1005 raise OSError(f"Tunnel connection failed: {code} {message.strip()}")
1006
1007 finally:
1008 response.close()
1009
1010 def get_proxy_response_headers(self):
1011 """

Callers 1

connectMethod · 0.95

Calls 12

_wrap_ipv6Method · 0.95
sendMethod · 0.95
closeMethod · 0.95
_read_headersFunction · 0.85
_read_statusMethod · 0.80
encodeMethod · 0.45
itemsMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
decodeMethod · 0.45
stripMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected