Httpx includes ipv6 scope in Host header
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 78
- Avg merge
- 8h 59m
- Merged PRs (30d)
- 24
Description
Originally opened by
@elupuson 2022-04-11 14:43:59 in encode/httpx
When requesting http paths with scope as part of the ipv6 address, this should stripped before being added to the http host header since it's fully local feature of the ipv6 stack.
Http over link local addresses is quite common on upnp based announces on link local networks.
Apache for example will reject the request: https://bz.apache.org/bugzilla/show_bug.cgi?id=35122
Lighthttpd: https://redmine.lighttpd.net/issues/2442
Example to reproduce:
import httpx
import respx
`@respx`.mock
def test_example():
my_route = respx.get("https://[fe80::8fd:8e9a:40d8:29a6%en0]/get")
my_route.mock(return_value=httpx.Response(204))
r = httpx.get(r'https://[fe80::8fd:8e9a:40d8:29a6%en0]/get')
print(my_route.calls[0].request.headers["host"])
assert my_route.calls[0].request.headers["host"] == "[fe80::8fd:8e9a:40d8:29a6]"
test_example()
- Initially raised as discussion #...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the test_example reproduction using httpx and respx, then trace how the request URL becomes the HTTP Host header. The work is done when the shown assertion passes for a scoped IPv6 address without regressing ordinary host headers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100