'IHttpClientFactory example implementation without relying on Microsoft.Extensions.Http implementation

What's the right way to implement IHttpClientFactory without using the default implementation in the Microsoft.Extensions.Http package. The built-in implementation only works as an injectable dependency and sometimes I don't need any sort of dependency injection just to make the system simple. I have searched the github repository but I couldn't find the source code.

The interface comes with a single method CreateClient which has a single parameter name. The issue is that what happens if the developer registers multiple clients for the same URL using different names? I guess that even the default implementation does not address that problem and it creates one HttpClient per key and reuses that under the hood. That's why I am looking for an example implementation just to make how exactly it works and just in case I would need to customize the default behavior.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source