Skip to content

HTTPSConnection double wrapping IPv6 address during CONNECT #100985

Closed

Description

@derekhiggins

Bug report

when http.client.HTTPSConnection is used with IPv6 addresses and a proxy results in the "Host:" Header being
wrapped in square brackets twice. (e.g. Host: [[fd2e:6f44:5dd8:c956::15]]:5050 )

$ cat /tmp/proxy_test.py
import http.client, ssl
conn = http.client.HTTPSConnection("fd2e:6f44:5dd8:c956::1", 8215, context=ssl._create_unverified_context())
conn.set_tunnel("[fd2e:6f44:5dd8:c956::15]", 5050)
conn.request("GET", "/", "")
response = conn.getresponse()
print(response.status, response.reason)

$ python3 /tmp/proxy_test.py
400 Bad Request


=== tcp dump showing extra squar brackets in "Host:" header ==
CONNECT [fd2e:6f44:5dd8:c956::15]:5050 HTTP/1.0

HTTP/1.1 200 Connection established

GET / HTTP/1.1
Host: [[fd2e:6f44:5dd8:c956::15]]:5050
Accept-Encoding: identity
Content-Length: 0

HTTP/1.1 400 Bad Request
Date: Thu, 12 Jan 2023 11:47:38 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1


Your environment

$ cat /etc/redhat-release
Red Hat Enterprise Linux CoreOS release 4.12

$ rpm -qf /usr/bin/python3
python3-3.9.10-4.el9_0.x86_64

Linked PRs

Activity

  1. added 4 commits that reference this issue on Jan 12, 2023
  2. added a commit that references this issue on Jan 26, 2023
  3. added a commit that references this issue on Feb 2, 2023
  4. added a commit that references this issue on Feb 23, 2023
  5. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 25, 2023
  6. added a commit that references this issue on Feb 17, 2024
  7. added a commit that references this issue on Feb 17, 2024
  8. added 2 commits that reference this issue on Feb 17, 2024
  9. added a commit that references this issue on Feb 17, 2024
  10. added a commit that references this issue on Mar 4, 2024
  11. added a commit that references this issue on Apr 17, 2024
  12. added a commit that references this issue on Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions