Add public Origin API
Merged
KL
3mo ago+203+203+012345678901234567890123456789-21-21-01234567890123456789
Summary
- add a public, immutable, and hashable
Originvalue object - expose normalized origins through
URL.origin - support effective ports for FTP, HTTP(S), and WS(S), including canonical IPv6 comparison
- use the shared value object for existing origin comparisons
- document and test the public API
Motivation
Applications and integrations sometimes need a reusable representation of a URL's scheme, host, and effective port. Origin provides that representation without including user information, paths, queries, or fragments.
Testing
pytest: 1,967 passed, 1 skippedruff format --check --diffruff checkmypy src/httpx2 tests/httpx2 src/httpcore2 tests/httpcore2python scripts/unasync.py --check