Skip to content

Ignore empty Alt-Svc values instead of throwing NullReferenceException - #136301

Merged
MihaZupan merged 2 commits into
dotnet:mainfrom
Tomius:main
Oct 22, 2026
Merged

MihaZupan merged 2 commits into
dotnet:mainfrom
Tomius:main

Conversation

@Tomius

@Tomius Tomius commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

AltSvcHeaderParser accepts an Alt-Svc header that is empty or contains only separators ("Alt-Svc:" or "Alt-Svc: ,") but produces a null parsed value for it. Since #114528, HandleAltSvc asserts that the value is non-null and then dereferences it. As a result, in Release builds any HTTPS response carrying such a header fails with a NullReferenceException whenever HTTP/3 support is enabled (the default), even for HTTP/1.1 and HTTP/2 requests.

Skip values that don't parse to an AltSvcHeaderValue, which restores the .NET 9 behavior. Add a functional test covering empty and separator-only values over HTTP/1.1 and HTTP/2.

Fixes #136291

AltSvcHeaderParser accepts an Alt-Svc header that is empty or contains
only separators ("Alt-Svc:" or "Alt-Svc: ,") but produces a null parsed
value for it. Since dotnet#114528, HandleAltSvc asserts that the value is
non-null and then dereferences it. As a result, in Release builds any
HTTPS response carrying such a header fails with a
NullReferenceException whenever HTTP/3 support is enabled (the
default), even for HTTP/1.1 and HTTP/2 requests.

Skip values that don't parse to an AltSvcHeaderValue, which restores
the .NET 9 behavior. Add a functional test covering empty and
separator-only values over HTTP/1.1 and HTTP/2.

Fixes dotnet#136291
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 22, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@MihaZupan MihaZupan added this to the 12.0.0 milestone Oct 22, 2026
@MihaZupan
MihaZupan enabled auto-merge (squash) October 22, 2026 18:31
@MihaZupan
MihaZupan merged commit c55a960 into dotnet:main Oct 22, 2026
86 of 88 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net.Http community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullReferenceException in HttpConnectionPool.HandleAltSvc when a response has an empty Alt-Svc header (regression in .NET 10)

2 participants