Omit IPv6 zone identifiers from automatic Host headers
MB
2mo ago+93+93+01234567890123456789-4-4-0123456789
Summary
Closes #676. A scoped IPv6 URL such as http://[fe80::1%eth0]/ currently sends the local zone identifier in the HTTP Host header, which servers can reject. Generate Host: [fe80::1] while keeping the scope in the URL and connection destination.
The formatter is used by standalone Request construction and redirects, covering sync and async clients. It preserves IPv6 brackets, non-default ports, normal explicit Host overrides, and the existing cross-origin Host rewrite. URL.netloc, stringification, and raw host remain unchanged.
The Core proxy-authority bracketing work in #1091 is separate; this PR does not change proxy serialization or scoped TLS behavior.
Validation
- 30 focused header tests passed. The exact final test file against the old source had five failures and 25 passes; the failures cover the reported scope leak.
scripts/checkpassed (lock, format, mypy, Ruff, unasync). Both packages built and passedtwine check; the main docs build retains six existing unresolved-reference warnings.- Full Linux CI passed Python 3.10–3.15, all original build/check steps, and 100% coverage. Python 3.10 had 2018 passed; the other versions had 2017 passed and one skipped.
- CI head
eab9febfdiffers from product headeaadfcf6only at.github/workflows/main.yml(manual trigger and disabled docs deployment). All 224 tracked paths were compared; original test/check job bytes, action pins, matrix and permissions are unchanged. The PR retains the upstream workflow. - Real
::1%lo0HTTP socket checks covered six sync/async/default/explicit/redirect cases and eight wire requests, both from source and an installed wheel. TCP destination scope was retained; Host formatting and cross-origin authorization removal matched expectations. This validates scoped loopback HTTP, not general link-local routing, TLS or proxy support. - Full local Mac tests retain the known system-proxy failures; the complete Linux run above passed.
Checklist
- I understand that this PR may be closed in case there was no previous discussion.
- I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
- I've updated the documentation accordingly. No public API or configuration changes; the internal formatter documents its purpose.