WasiHttpClient Class

The HTTP client of a WASI component (wasi:http/client, see WasiOptions.HttpClient): it sends the requests of the component. WasiHostHttpClient sends them over the network of the machine, with the rules of a WasiHostHttpClientOptions; WasiInMemoryHttpClient gives them to a handler of the process.

public abstract class WasiHttpClient

Remarks

WASI validates the requests of the component before calling the client (the method, the scheme, the authority, the path, the headers). The content of a request is the body that the component writes, read as it sends it. The content of the response is read by the component as the client receives it; its trailers are HttpResponseMessage.TrailingHeaders. An exception reports an error to the component: a HttpRequestException (whose inner exception can be a SocketException), a TimeoutException, or an UnauthorizedAccessException for a request that the client denies.

Constructors

NameDescription
WasiHttpClient()

WasiHttpClient()

protected WasiHttpClient()

No documentation is available.

Properties

NameDescription
RequestTrailersGets the key of the trailers of a request in HttpRequestMessage.Options: a task that completes with the trailers that the component sends after the body (or null), once the content of the request is read. The clients that cannot send trailers (HTTP/1.1 of .NET) ignore them.

RequestTrailers

WasiHttpClient.cs

Gets the key of the trailers of a request in HttpRequestMessage.Options: a task that completes with the trailers that the component sends after the body (or null), once the content of the request is read. The clients that cannot send trailers (HTTP/1.1 of .NET) ignore them.

public static HttpRequestOptionsKey<Task<HttpHeaders?>> RequestTrailers { get; }

Methods

NameDescription
SendAsync(HttpRequestMessage, CancellationToken)Sends a request, and returns the response once its headers are received.

SendAsync(HttpRequestMessage, CancellationToken)

Sends a request, and returns the response once its headers are received.

public abstract Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

Parameters

request HttpRequestMessage
The request.
cancellationToken CancellationToken
The token that is cancelled when the component cancels the request.

Returns

Task<HttpResponseMessage> The response.