Edit

Share via


HttpVersion Class

Definition

Defines the HTTP version numbers that are supported by the HttpWebRequest and HttpWebResponse classes.

C#
public static class HttpVersion
C#
public class HttpVersion
Inheritance
HttpVersion

Examples

The following example demonstrates the use of HttpVersion.

C#
// HttpClient lifecycle management best practices:
// https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use
using HttpClient client = new HttpClient();

using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://www.microsoft.com");
Console.WriteLine("Default HTTP request version is {0}", request.Version);

request.Version = HttpVersion.Version10;
Console.WriteLine("Request version after assignment is {0}", request.Version);

using HttpResponseMessage response = client.Send(request);
Console.WriteLine("Response HTTP version {0}", response.Version);

Remarks

The HttpVersion class defines the HTTP versions that are supported by the HttpClient class. The HTTP version number is used to control version-specific features of HTTP, such as pipelining and chunking.

Constructors

HttpVersion()

Initializes a new instance of the HttpVersion class.

Fields

Unknown

Defines a Version instance for an unknown HTTP version.

Version10

Defines a Version instance for HTTP 1.0.

Version11

Defines a Version instance for HTTP 1.1.

Version20

Defines a Version instance for HTTP 2.0.

Version30

Defines a Version instance for HTTP 3.0.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1