-
-
Notifications
You must be signed in to change notification settings - Fork 798
Docs: Added examples for With-methods #8650
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
Conversation
Test: Added validation for disposed HttpClient
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.
I emphasized this since it was very common in .NET Framework 4 to have one singleton HttpClient-instance that is used for each and every request.
This is also still the recommended way (docs) if one doesn`t use dependency injection / IHttpClientFactory.
With this in mind, something like
private static readonly HttpClient httpClient = new HttpClient();
var result1 = await client.GetSomething.WithHttpClient(httpClient).ExecuteAsync();
var result2 = await client.GetSomethingElse.WithHttpClient(httpClient).ExecuteAsync();
...
will break.
I wonder whether it might make sense to add a boolean to control whether the client should be disposed to WithHttpClient (I could add that) @michaelstaib
Summary of the changes (Less than 80 chars)
Related