Skip to content

Preserve response status in HTTP authentication drain failures - #136795

Open
RutulPatel8 wants to merge 2 commits into
dotnet:mainfrom
RutulPatel8:fix/http-request-status-code-105700
Open

RutulPatel8 wants to merge 2 commits into
dotnet:mainfrom
RutulPatel8:fix/http-request-status-code-105700

Conversation

@RutulPatel8

@RutulPatel8 RutulPatel8 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #105700

HttpConnection.DrainResponseAsync throws HttpRequestException for two authentication drain failures after receiving a response. Those exceptions did not carry the response status, even though it is available at both call sites.

Pass response.StatusCode to the exception so callers can inspect the failed authentication response. The proxy tunnel case identified in the issue already forwards its status on current main. Added NTLM loopback tests for both the pre-drain close and size-limit drain failure paths.

Validation: the System.Net.Http library and Windows functional test project build with zero warnings or errors. Both new tests reach the intended failure paths and reproduce the missing status against the installed unpatched runtime. The PR-built runtime could not be run locally because the repository testhost requires Visual Studio C++ tools on this machine.

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 1, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 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

Copy link
Copy Markdown
Member

Can you please add test cases for these fixes?

@RutulPatel8

Copy link
Copy Markdown
Contributor Author

I added two NTLM loopback tests in 6447d4a for the pre-drain close and size-limit drain paths. Both assert UserAuthenticationError and the 401 status. They compile, and both reproduce the missing StatusCode against the installed unpatched runtime. The PR description now includes the validation details.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

Forward StatusCode to HttpRequestException whenever possible

2 participants