-
Notifications
You must be signed in to change notification settings - Fork 763
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
API that allows to remove all assigned handlers from the HTTP client #5801
base: main
Are you sure you want to change the base?
Conversation
{ | ||
for (int i = handlers.Count - 1; i >= 0; i--) | ||
{ | ||
handlers.RemoveAt(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will remove all http message handler types, but we need to remove only handlers of type ResilienceHandler
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=923055&view=codecoverage-tab |
Background and motivation
.NET provides the ConfigureHttpClientDefaults method that allows you to configure the default behavior of the HttpClient. With the help of this method you can register the StandardResiliencePipeline as part of the default configuration of the HttpClient:
services.ConfigureHttpClientDefaults(builder => builder.AddStandardResilienceHandler());
This is convenient, since you don't need to configure the resilience pipeline for each HttpClient. But with the API we currently provide users face a few issues/challenges when they need to change the default configuration. This change focuses on the following issue:
Removing the existing default resilience pipeline and adding a custom one
For example, a user registers the
StandardResilienceHandler
as default configuration, but at the same time he/she wants to use theStandardHedgingHandler
for a particular namedHttpClient
:API description
This API provides functionality to remove all assigned handlers from the HttpClient.
API Usage
This PR partially resolves #5695
Microsoft Reviewers: Open in CodeFlow