-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP 400 ("Invalid Host header") for link-local IPv6 addresses #59341
Comments
https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
https://datatracker.ietf.org/doc/html/rfc7230#section-2.7.1
https://datatracker.ietf.org/doc/html/rfc6874#section-2
https://datatracker.ietf.org/doc/html/rfc6874#section-4
This would appear to be a HttpClient bug. It needs the zone id to identify the right interface, but then it must remove that from the outgoing host header. |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescribe the bugOn Linux, it doesn't seem to be possible to do a requests through a link-local IPv6 address. Link-local IPv6 addresses have the following format: If you want to make a request to this address, you basically have two options: with or without the If you keep the
If you remove the
From what I could gather, the I'm not sure who the "culprit" is here - but it seems to me that Kestrel should allow To ReproduceI've created a reproducer here: https://github.com/skrysmanski/reproducer-kestel-ipv6-github-bug The primary test code is here (method You can find a Linux GitHub Actions run here: https://github.com/skrysmanski/reproducer-kestel-ipv6-github-bug/actions/runs/1252686642 This run contains the Exceptions (if any)Complete test log for run with
Exception log for test run without
Further technical details
|
You can probably work around this by setting the request URI to |
I've verified that (for my limited scope) this is indeed the fix: var requestUri = new Uri(requestUriAsString);
var requestMessage = new HttpRequestMessage(HttpMethod.Get, requestUri);
requestMessage.Headers.Host = requestUri.Authority; // the fix
var response = await s_httpClient.SendAsync(requestMessage); Not sure whether The fix works on Windows, too. |
Describe the bug
On Linux, it doesn't seem to be possible to do a requests through a link-local IPv6 address.
Link-local IPv6 addresses have the following format:
fe80::...%...
(e.g.fe80::20d:3aff:fe6d:4068%2
).If you want to make a request to this address, you basically have two options: with or without the
%2
part.If you keep the
%2
part, you'll get a HTTP 400 (Bad request) both on Windows and on Linux. In this case, Kestrel logs:If you remove the
%2
part, it works on Windows but on Linux you'll get aHttpRequestException
saying:From what I could gather, the
%2
is required on Linux but (apparently) not on Windows (see: https://stackoverflow.com/q/12260003/614177).I'm not sure who the "culprit" is here - but it seems to me that Kestrel should allow
[fe80::20d:3aff:fe6d:4068%2]:1234
as host header.To Reproduce
I've created a reproducer here: https://github.com/skrysmanski/reproducer-kestel-ipv6-github-bug
The primary test code is here (method
TestConnection()
): https://github.com/skrysmanski/reproducer-kestel-ipv6-github-bug/blob/main/Reproducer/ReproducerTest.csYou can find a Linux GitHub Actions run here: https://github.com/skrysmanski/reproducer-kestel-ipv6-github-bug/actions/runs/1252686642
This run contains the
.trx
files and a test report.Exceptions (if any)
Complete test log for run with
%2
:Exception log for test run without
%2
:Further technical details
The text was updated successfully, but these errors were encountered: