HttpVersion Class

Definition

定义 HttpWebRequestHttpWebResponse 类支持的 HTTP 版本号。Defines the HTTP version numbers that are supported by the HttpWebRequest and HttpWebResponse classes.

public ref class HttpVersion abstract sealed
public ref class HttpVersion
public static class HttpVersion
public class HttpVersion
type HttpVersion = class
Public Class HttpVersion
Inheritance
HttpVersion

Examples

以下示例演示了 HttpVersion 的用法。The following example demonstrates the use of HttpVersion.

// Create a 'HttpWebRequest' object.
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.microsoft.com" ) );
Console::WriteLine( "\nThe 'ProtocolVersion' of the protocol before assignment is : {0}", myHttpWebRequest->ProtocolVersion );
// Assign Version10 to ProtocolVersion.
myHttpWebRequest->ProtocolVersion = HttpVersion::Version10;
// Assign the response Object* of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() );
Console::WriteLine( "\nThe 'ProtocolVersion' of the protocol after  assignment is : {0}", myHttpWebRequest->ProtocolVersion );
Console::WriteLine( "\nThe 'ProtocolVersion' of the response Object* is : {0}", myHttpWebResponse->ProtocolVersion );
// Create a 'HttpWebRequest' object.
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
Console.WriteLine("\nThe 'ProtocolVersion' of the protocol before assignment is :{0}",myHttpWebRequest.ProtocolVersion);
// Assign Version10 to ProtocolVersion.
myHttpWebRequest.ProtocolVersion=HttpVersion.Version10;
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();
Console.WriteLine("\nThe 'ProtocolVersion' of the protocol after  assignment is :{0}",myHttpWebRequest.ProtocolVersion);
Console.WriteLine("\nThe 'ProtocolVersion' of the response object is :{0}",myHttpWebResponse.ProtocolVersion);
' Create a 'HttpWebRequest' object.
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.microsoft.com"), HttpWebRequest)
Console.WriteLine(ControlChars.Cr + "The 'ProtocolVersion' of the protocol before assignment is :{0}", myHttpWebRequest.ProtocolVersion)
' Assign Version10 to ProtocolVersion.
myHttpWebRequest.ProtocolVersion = HttpVersion.Version10
' The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Console.WriteLine(ControlChars.Cr + "The 'ProtocolVersion' of the protocol after  assignment is :{0}", myHttpWebRequest.ProtocolVersion)
Console.WriteLine(ControlChars.Cr + "The 'ProtocolVersion' of the response object is :{0}", myHttpWebResponse.ProtocolVersion)

Remarks

HttpVersion 类定义 HttpWebRequestHttpWebResponse 类支持的 HTTP 版本。The HttpVersion class defines the HTTP versions that are supported by the HttpWebRequest and HttpWebResponse classes. HTTP 版本号用于控制 HTTP 的特定于版本的功能,如流水线和分块。The HTTP version number is used to control version-specific features of HTTP, such as pipelining and chunking.

Constructors

HttpVersion()

初始化 HttpVersion 类的新实例。Initializes a new instance of the HttpVersion class.

Fields

Unknown

定义用于未知 HTTP 版本的 Version 实例。Defines a Version instance for an unknown HTTP version.

Version10

定义用于 HTTP 1.0 的 Version 实例。Defines a Version instance for HTTP 1.0.

Version11

定义用于 HTTP 1.1 的 Version 实例。Defines a Version instance for HTTP 1.1.

Version20

定义用于 HTTP 2.0 的 Version 实例。Defines a Version instance for HTTP 2.0.

Version30

Applies to