Skip to content

net/http: use consistent IDNA processing for dial target and Host header - #253

Open
kingljl wants to merge 4 commits into
golang:masterfrom
kingljl:fix-net-http-client-dials--iDNA
Open

net/http: use consistent IDNA processing for dial target and Host header#253
kingljl wants to merge 4 commits into
golang:masterfrom
kingljl:fix-net-http-client-dials--iDNA

Conversation

@kingljl

@kingljl kingljl commented Jul 17, 2026

Copy link
Copy Markdown

Changes:

  • internal/httpcommon/request.go: use idna.Lookup.ToASCII (UTS Replaced link in comment for gzip/deflate with valid one #46
    with mapping) when computing the Host / :authority header. Add the
    idnaASCIIHostPort helper.
  • http2/transport_common.go: use idna.Lookup.ToASCII in authorityAddr
    for the HTTP/2 dial target, so the connection pool key, dialed
    address, and header agree.
  • Add TestEncodeHeadersIDNAMapping and TestAuthorityAddrIDNAMapping.

Fixes golang/go#80417

kingljl added 4 commits July 17, 2026 14:25
Updated IDNA processing to use idna.Lookup.ToASCII for host conversion, ensuring consistency with net/http Transport.
Add TestAuthorityAddrIDNAMapping to verify IDNA processing
Added IDNA processing for host in request handling.
Add a test for IDNA mapping in EncodeHeaders function.
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: e5588eb) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/net/+/802060.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

net/http: Client dials an IDNA-mapped host differing from url.Hostname() and Host header

2 participants