Repository navigation
Fix telemetry for redirect + custom ICredentials - #115939
Merged
antonfirsov merged 4 commits intoJun 9, 2025
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/ncl |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors authentication handling in SocketsHttpHandler by consolidating two handler types into one with a configurable auth flag, updates redirect logic to disable auth via a request flag, and extends tests to cover different credential modes.
- Merged
HttpConnectionHandlerandHttpAuthenticatedConnectionHandlerinto a single handler using adoRequestAuthparameter. - Simplified
RedirectHandlerto flip an auth-disabled flag onHttpRequestMessageinstead of swapping handlers. - Converted redirect span tests to a
[ConditionalTheory]with inline data for null,CredentialCache, and custom credentials.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| MetricsTest.cs | Updated redirect metrics test to a [ConditionalTheory] with three credential modes and added CustomCredentials. |
| SocketsHttpHandler.cs | Always instantiate HttpConnectionHandler with doRequestAuth flag and pass disableAuthOnRedirect to RedirectHandler. |
| RedirectHandler.cs | Removed dual handlers, introduced _disableAuthOnRedirect, and call request.DisableAuth() for redirects. |
| HttpConnectionHandler.cs | Added _doRequestAuth field and have SendAsync respect the request’s disabled-auth flag. |
| HttpAuthenticatedConnectionHandler.cs | Removed obsolete authenticated handler and its project entry. |
| HttpRequestMessage.cs | Added AuthDisabled bit flag and internal methods DisableAuth/IsAuthDisabled. |
Comments suppressed due to low confidence (1)
src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestMessage.cs:22
- Add unit tests for
HttpRequestMessage.DisableAuthandIsAuthDisabledto verify that the auth-disabled flag is correctly set and interpreted during redirects.
private const int AuthDisabled = 8;
ManickaP
approved these changes
May 23, 2025
ManickaP
left a comment
Member
There was a problem hiding this comment.
This is a great change! I'm glad to see HttpAuthenticatedConnectionHandler gone!
![]()
MihaZupan
approved these changes
May 23, 2025
Open
3 tasks
Contributor
Author
|
/azp run runtime-libraries-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #115938.
Instead of having two separated handler types, this PR proposes to store a bool in
HttpConnectionHandlerand manages the disabling of the auth by flipping a flag onHttpRequestMessage.