dimanche 1 octobre 2017

How to set an HttpHeader on for a specific connection of HttpClient?

The most suggested question doesn't have the answer.

I would like to set a specific header for the entire http connection which HttpClient establishes and maintains (keep-alive is set to true), that is,

each request I make should contain my custom header. Obviously,

_httpClient.DefaultRequestHeaders.Add("MyHeader", "MyValue");

is not an option, since it sets the header for the entire HttpClient, whereas I would like to have it only for the specific connection, which is created when I make my first call to a URL at a server.

That server then keeps the connection alive and expects me to have a MyHeader header for each subsequent request that I make while the connection is .




Aucun commentaire:

Enregistrer un commentaire