Repository navigation
httpclient: Support IDN hostnames in URLs and redirects - #3873
Merged
bdarnell merged 1 commit intoNov 13, 2026
Merged
Conversation
bdarnell
force-pushed
the
claude/project-thread-rdyj8b
branch
2 times, most recently
from
November 13, 2026 19:40
f6aed97 to
570ed94
Compare
Convert non-ASCII hostnames with IDNA and percent-encode other non-ASCII characters as UTF-8, as browsers do, in a shared helper (httputil._url_to_ascii) used by both simple_httpclient and curl_httpclient. Both clients now accept IDN URLs (tornadoweb#1490), and simple_httpclient sends the IDNA form in the Host header instead of raw latin1. When following a redirect, simple_httpclient decodes the Location header as UTF-8 and converts it the same way. This replaces the percent-encoding of the raw header bytes from tornadoweb#3860, which also percent-encoded the hostname (tornadoweb#3870). Like browsers, a Location header that is not valid UTF-8 is now an error. Previously a latin1 hostname happened to work, but it was sent in the Host header without IDNA conversion and a UTF-8 hostname did not work at all. The tests move to the common httpclient tests. libcurl follows redirects itself, so the redirect tests are skipped for curl_httpclient where its behavior differs: it percent-encodes non-UTF-8 bytes, and converts IDN hostnames only when built with IDN support. Fixes tornadoweb#1490 Closes tornadoweb#3870 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VamvWqdwiBTCFwhDLCbBee
bdarnell
force-pushed
the
claude/project-thread-rdyj8b
branch
from
November 13, 2026 20:12
570ed94 to
f8290ae
Compare
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert non-ASCII hostnames with IDNA and percent-encode other non-ASCII
characters as UTF-8, as browsers do, in a shared helper
(httputil._url_to_ascii) used by both simple_httpclient and
curl_httpclient. Both clients now accept IDN URLs (#1490), and
simple_httpclient sends the IDNA form in the Host header instead of raw
latin1.
When following a redirect, simple_httpclient decodes the Location header
as UTF-8 and converts it the same way. This replaces the percent-encoding
of the raw header bytes from #3860, which also percent-encoded the
hostname (#3870). Like browsers, a Location header that is not valid
UTF-8 is now an error. Previously a latin1 hostname happened to work,
but it was sent in the Host header without IDNA conversion and a UTF-8
hostname did not work at all.
The tests move to the common httpclient tests. libcurl follows redirects
itself, so the redirect tests are skipped for curl_httpclient where its
behavior differs: it percent-encodes non-UTF-8 bytes, and converts IDN
hostnames only when built with IDN support.
Fixes #1490
Closes #3870
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01VamvWqdwiBTCFwhDLCbBee