I have HttpClient httpClient injected from outside of my class.
Inside my class I'm creating a new HttpClientHandler var handler = new HttpClientHandler() and setting its values.
I need to link HttpClientHandler to existing HttpClient the same way you can do it using the constructor: new HttpClient(handler)
Is it possible? I've tried looking for HttpClientHandler property within HttpClient but it does not exist. Is there any other way?
No, you can't.
HttpClient class does not hold a reference to the underlying HttpMessageHandler.HttpClientHandler or a SocketsHttpHandler to the HttpClient's constructor then it is passing the handler to its base class's constructor.HttpMessageInvoker where the _handler field is defined as readonly.HttpClient instance.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With