HttpMessageInvoker.Send(HttpRequestMessage, CancellationToken) 方法

定义

发送带有指定请求和取消标记的 HTTP 请求。

public:
 virtual System::Net::Http::HttpResponseMessage ^ Send(System::Net::Http::HttpRequestMessage ^ request, System::Threading::CancellationToken cancellationToken);
public virtual System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual System.Net.Http.HttpResponseMessage Send (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken);
abstract member Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
override this.Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
abstract member Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
override this.Send : System.Net.Http.HttpRequestMessage * System.Threading.CancellationToken -> System.Net.Http.HttpResponseMessage
Public Overridable Function Send (request As HttpRequestMessage, cancellationToken As CancellationToken) As HttpResponseMessage

参数

request
HttpRequestMessage

要发送的 HTTP 请求消息。

cancellationToken
CancellationToken

取消操作的取消标记。

返回

HTTP 响应消息。

属性

例外

requestnull

用于 HTTP/2 和更高版本,或者 RequestVersionOrHigher 启用了请求版本升级时。

如果使用派生自 HttpContent 的自定义类不重写 SerializeToStream(Stream, TransportContext, CancellationToken) 方法。

如果使用自定义 HttpMessageHandler 不重写 Send(HttpRequestMessage, CancellationToken) 方法。

取消令牌已取消。 此异常存储在返回的任务中。

适用于