Udostępnij za pośrednictwem


HttpRequestMessage Class

Definition

Represents an HTTP request message including headers.

public ref class HttpRequestMessage sealed : IClosable, IStringable
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.IHttpRequestMessageFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpRequestMessage final : IClosable, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.IHttpRequestMessageFactory, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class HttpRequestMessage final : IClosable, IStringable
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.IHttpRequestMessageFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpRequestMessage : System.IDisposable, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.IHttpRequestMessageFactory), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class HttpRequestMessage : System.IDisposable, IStringable
function HttpRequestMessage(method, uri)
Public NotInheritable Class HttpRequestMessage
Implements IDisposable, IStringable
Inheritance
Object Platform::Object IInspectable HttpRequestMessage
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

The HttpRequestMessage class contains headers, the HTTP verb, and potentially data. This class is commonly used by developers who need additional control over HTTP requests. Common examples include the following:

  • To examine the underlying SSL/TLS transport information.
  • To use a less-common HTTP method.
  • To explicitly set request properties on the HttpRequestMessage.

In these cases, an app uses one of the HttpRequestMessage constructors to create an HttpRequestMessage instance. The app sets various properties on the HttpRequestMessage as needed. Then the HttpRequestMessage is passed as a parameter to one of the HttpClient.SendRequestAsync methods.

A number of convenience methods on the HttpClient class automatically create an HttpRequestMessage object for the app. These methods include the following:

Any filters that you add to the filter pipeline will be passed the HttpRequestMessage object whether it was explicitly specified by the app or was automatically constructed for you.

Constructors

HttpRequestMessage()

Initializes a new instance of the HttpRequestMessage class.

HttpRequestMessage(HttpMethod, Uri)

Initializes a new instance of the HttpRequestMessage class with an HTTP method and a request Uri.

Properties

Content

Gets or sets the HTTP content to send to the server on the HttpRequestMessage object.

Headers

Gets the collection of the HTTP request headers associated with the HttpRequestMessage.

Method

Gets or sets the HTTP method to be performed on the request URI.

PrivacyAnnotation
Properties

Gets a set of properties on the HttpRequestMessage instance that are for use by the developer.

RequestUri

Gets or sets the Uri used for the HttpRequestMessage object.

TransportInformation

Get information about the underlying transport socket used by an HTTP connection.

Methods

Close()

Closes the HttpRequestMessage instance and releases allocated resources.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

ToString()

Returns a string that represents the current HttpRequestMessage object.

Applies to

See also