Set HTTP protocol version in HttpClient

I need to make a request to a web service that uses HTTP version 1.0. I use HttpClient , but I do not see any option to install the HTTP version.

Where can I install the request version?

+6
source share
2 answers

To install the version, you need to create an instance of HttpRequestMessage and set its Version property, which you will go to HttpClient.SendAsync . You can use the helper class HttpVersion :

 var requestMessage = new HttpRequestMessage { Version = HttpVersion.Version10 }; var client = new HttpClient(); var response = await client.SendAsync(requestMessage); 
+7
source

The HTTP version is sent as a header in each request, so it is set in the message sent to System.Net.Http.HttpClient: see ProtocolVersion of the HttpWebRequest class.

0
source

Source: https://habr.com/ru/post/981418/


All Articles