I have to unit test class that use HttpRequestHeaders as parameter.
public HeaderValueProvider(HttpRequestHeaders headers) { _headers = headers; }
HttpRequestHeaders
has only internal constructor. But you can do it by creating HttpRequestMesssage
object:
using var headers = new HttpRequestMessage().Headers;
You can get a blank instance of HttpRequestHeaders
via:
var headers = new HttpClient().DefaultRequestHeaders;
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