diff options
| author | shadchin <[email protected]> | 2024-04-28 21:17:44 +0300 |
|---|---|---|
| committer | shadchin <[email protected]> | 2024-04-28 21:25:54 +0300 |
| commit | a55d99a3eb72f90355bc146baeda18aa7eb97352 (patch) | |
| tree | b17cfed786effe8b81bba022239d6729f716fbeb /contrib/tools/python3/Lib/http | |
| parent | 67bf49d08acf1277eff4c336021ac22d964bb4c4 (diff) | |
Update Python 3 to 3.12.3
7d09de7d8b99ea2be554ef0fc61276942ca9c2e1
Diffstat (limited to 'contrib/tools/python3/Lib/http')
| -rw-r--r-- | contrib/tools/python3/Lib/http/client.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/contrib/tools/python3/Lib/http/client.py b/contrib/tools/python3/Lib/http/client.py index 5eebfccafbc..a353716a850 100644 --- a/contrib/tools/python3/Lib/http/client.py +++ b/contrib/tools/python3/Lib/http/client.py @@ -936,17 +936,23 @@ class HTTPConnection: host = host[:i] else: port = self.default_port - if host and host[0] == '[' and host[-1] == ']': - host = host[1:-1] + if host and host[0] == '[' and host[-1] == ']': + host = host[1:-1] return (host, port) def set_debuglevel(self, level): self.debuglevel = level + def _wrap_ipv6(self, ip): + if b':' in ip and ip[0] != b'['[0]: + return b"[" + ip + b"]" + return ip + def _tunnel(self): connect = b"CONNECT %s:%d %s\r\n" % ( - self._tunnel_host.encode("idna"), self._tunnel_port, + self._wrap_ipv6(self._tunnel_host.encode("idna")), + self._tunnel_port, self._http_vsn_str.encode("ascii")) headers = [connect] for header, value in self._tunnel_headers.items(): @@ -1221,9 +1227,8 @@ class HTTPConnection: # As per RFC 273, IPv6 address should be wrapped with [] # when used as Host header - + host_enc = self._wrap_ipv6(host_enc) if ":" in host: - host_enc = b'[' + host_enc + b']' host_enc = _strip_ipv6_iface(host_enc) if port == self.default_port: |
