To access the demos, checkout the respective tag.
git checkout tags/single-use-httpclient --force --quiet
The demo accesses https://bing.com/ and https://api.github.com/. Due to the high intensity of the requests, those websites might (they will!) throttle the requests.
To monitor for TIME_WAIT connections to these destinations, use the following PowerShell command:
while ($true) { (Get-NetTCPConnection -RemoteAddress '13.107.21.200','204.79.197.200','140.82.118.6' -State TimeWait -ErrorAction Ignore).Count }
tag: single-use-httpclient
This demo uses a new instance of HttpClient
each time it's used.
tag: single-use-httpclient-connection-close
This demo uses a new instance of HttpClient
each time it's used with ConnectionClose
set to true
.
tag: single-use-httpclient-connection-close
This demo uses a singleton instance of HttpClient
for every use.
tag: single-use-httpclient-singleton-httpclienthandler
This demo uses a singleton instance of HttpClientHandler
in instances of HttpClient
for one-time use.
tag: httpclientfactory
This demo uses the implmentation of IHttpHandlerFactory
to create instances of HttpClient
for one-time use.
tag: httpclientfactory-named-httpclient
This demo uses the implmentation of IHttpHandlerFactory
to create instances of HttpClient
for one-time use using named definitions.
tag: httpclientfactory-typed-client
This demo uses the implmentation of IHttpHandlerFactory
to create instances of HttpClient
for one-time use using typed clients.
tag: httpclientfactory-socketshttphandler
This demo uses the implmentation of IHttpHandlerFactory
to create instances of HttpClient
for one-time use using a custom primary handler (SocketsHttpHandler
).
tag: httpclientfactory-polly
This demo uses the implmentation of IHttpHandlerFactory
to create instances of HttpClient
for one-time use using policies provided by Polly.
- TIME_WAIT
HttpClient
classSocketsHttpHandler
Class- Make HTTP requests using
IHttpClientFactory
in ASP.NET Core - Use IHttpClientFactory to implement resilient HTTP requests
- IHttpClientFactoryinterface
HttpClientBuilderExtensions
Class- Steve Gordon's blog posts on
HttpClient
[GitHub] [Twitter]HttpClient
Creation And Disposal Internals: Should I Dispose OfHttpClient
?- Demystifying
HttpClient
Internals: SendAsync Flow ForHttpRequestMessage
- Demystifying
HttpClient
Internals:HttpResponseMessage
HttpClient
Connection Pooling in .NET Core- Using
HttpCompletionOption
To ImproveHttpClient
Performance In .NET - Sending And Receiving JSON Using
HttpClient
WithSystem.Net.Http.Json
- Steve Gordon's blog posts on
IHttpClientFactory
[GitHub] [Twitter]- HttpClientFactory in ASP.NET Core 2.1 (Part 1): An Introduction To HttpClientFactory
- HttpClientFactory In ASP.NET Core 2.1 (Part 2): Defining Named And Typed Clients
- HttpClientFactory In ASP.NET Core 2.1 (Part 3): Outgoing Request Middleware With Handlers
- HttpClientFactory In ASP.NET Core 2.1 (Part 4): Integrating With Polly For Transient Fault Handling
IHttpClientFactory
Patterns: Using Typed Clients From Singleton Services- HttpClientFactory In ASP.NET Core 2.1 (Part 5): Logging
- Andrew Lock's blog posts on
IHttpClientFactory
[GitHub] [Twitter] - Damen Bod’s blog posts on
HttpClient
/IHttpClientFactory
[GitHub] [Twitter] - João Grassi [GitHub] [Twitter]