Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Class

HttpClient

class HttpClient

Module: System.Web.Http
Assembly: System.Web.dll
Source file: HttpClient.rvn

Inheritance: Object → HttpClient
Implements: Disposable

Sends requests through an injected handler pipeline; defaults to HttpSocketHandler.

Remarks

Development after Preview 9. Expected HTTP failures use the HttpError union, preserving DNS and socket causes. The socket transport admits HTTP/1.1 final statuses 200–599 using Content-Length, bounded chunked or close-delimited framing; HEAD/204/304 complete after headers, at most 32,768 header bytes, 100 fields and 1,048,576 body bytes. Chunk metadata is limited to 65,536 bytes; extensions and trailers are unsupported. HTTPS requires explicit SslClientAuthenticationOptions through HttpSocketHandler. No pooling, redirects or unknown-length uploads. Bounded informational responses are supported. ResponseHeadersRead transfers a one-shot body stream after final headers. Known-length stream uploads, buffered bodies and decoded incoming streams are limited to 1,048,576 bytes. HttpClient.Timeout covers the complete handler pipeline through the selected response completion point and defaults to 100 seconds. None disables the client countdown. DNS, connect and transfers retain independent five-second phase bounds, so transport failures can occur earlier. Direct HttpSocketHandler use has no client-wide countdown. Cancellation and expiry require scheduler progress and provider cleanup acknowledgement. See the Web feature guide for contracts and limits.

Constructors

3 items
HttpClient() Creates a client owning its default socket handler.
HttpClient(handler: HttpHandler, disposeHandler: bool) Creates a client with explicit handler ownership.
HttpClient(handler: HttpHandler) Creates a client which owns the supplied handler.

Properties

3 items
BaseUri: Optional<string> Optional absolute base URL, validated when a verb helper constructs a request.
DefaultRequestHeaders: Sequence<HttpHeader> Client-wide application headers, copied on get/set and validated at Send.
Timeout: Optional<Duration> The total cooperative request budget, including custom handlers and response buffering. Defaults to Some(100 seconds); None disables the client countdown. Positive durations throug…

Methods

21 items
Delete(uri: Uri, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Uses the same base-resolution rules as the string overload. Uses the same address rules, with cooperative cancellation.
Delete(url: string, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Sends DELETE without content to an absolute URL without a base, or a relative URL when BaseUri is set. Uses the same address rules, with cooperative cancellation.
Dispose() -> () Cancels pending requests and disposes the handler when this client owns it. Repeated disposal is harmless; completed responses remain caller-owned. Implements Disposable.Dispose
Equals(other: object?) -> bool Tests reference identity by default; an ordinary class may override equality. Inherited from Object.Equals
Get(uri: Uri, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Uses the same base-resolution rules as the string overload. Uses the same address rules, with cooperative cancellation.
Get(url: string, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Sends an absolute URL without a base, or a relative URL when BaseUri is set. Uses the same address rules, with cooperative cancellation.
GetHashCode() -> int Returns a stable identity hash by default; an ordinary class may override it consistently with equality. Inherited from Object.GetHashCode
GetString(uri: Uri, cancellationToken?: CancellationToken) -> Task<Result<string, HttpError>> Fetches a bounded response and decodes its buffered body as strict UTF-8. Fetches UTF-8 text, preserving HTTP failures and acknowledged task cancellation.
GetString(url: string, cancellationToken?: CancellationToken) -> Task<Result<string, HttpError>> Fetches a bounded response and decodes its buffered body as strict UTF-8. Fetches UTF-8 text, preserving HTTP failures and acknowledged task cancellation.
GetType() -> TypeInfo Returns metadata for the concrete runtime type of this instance. Inherited from Object.GetType
Head(uri: Uri, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Uses the same base-resolution rules as the string overload. Uses the same address rules, with cooperative cancellation.
Head(url: string, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Sends HEAD without content to an absolute URL without a base, or a relative URL when BaseUri is set. Uses the same address rules, with cooperative cancellation.
Patch(uri: Uri, content: HttpContent, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Sends PATCH content to a URI using the same base-resolution rules as Get. Sends PATCH content through Send, forwarding the cancellation token unchanged.
Patch(url: string, content: HttpContent, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Sends PATCH buffered content using the same BaseUri and handler rules as Get. Sends PATCH content with cooperative exchange cancellation.
Post(uri: Uri, content: HttpContent, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Posts content to a URI using the same base-resolution rules as Get. Posts content through Send, forwarding the cancellation token unchanged.
Post(url: string, content: HttpContent, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Posts buffered content using the same BaseUri and handler rules as Get. Posts content with cooperative exchange cancellation.
Put(uri: Uri, content: HttpContent, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Sends PUT content to a URI using the same base-resolution rules as Get. Sends PUT content through Send, forwarding the cancellation token unchanged.
Put(url: string, content: HttpContent, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Sends PUT buffered content using the same BaseUri and handler rules as Get. Sends PUT content with cooperative exchange cancellation.
Send(request: HttpRequest, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Sends a prepared request, forwarding the token through the handler pipeline.
Send(request: HttpRequest, completionOption: HttpCompletionOption, cancellationToken?: CancellationToken) -> Task<Result<HttpResponse, HttpError>> Selects buffered completion or ownership transfer at final response headers. Headers-only completion ends the client timeout; body reads require their own token.
ToString() -> string Returns the concrete runtime type name for supported references, or display text from a class or boxed-struct override. Inherited from Object.ToString