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

API Browser

Module

System.Web.Http

module System.Web.Http

HTTP requests, responses and handlers

HttpClient and HttpServer provide the bounded HTTP proof of concept. Requests, responses, headers and content describe exchanged messages; HttpContext and handler contracts connect server behavior and the replaceable client pipeline. RoutePattern and RouteMatch support the implemented routing surface.

See Web for the current cleartext scope, limits and tested samples. This preview is not a general production web stack. System.Web.Http.Json supplies JSON content and client helpers.

HttpClient.Timeout is an Optional<Duration>, defaulting to Some(100 seconds). None disables the client countdown. Configure it before sending. Expiry requests cancellation and waits for handler cleanup before returning HttpError.TimedOut; caller or disposal cancellation remains task cancellation. Independent transport phase bounds still apply. See HTTP contracts for limits and handler responsibilities.

HttpMethod provides canonical method properties, custom token construction and typed Parse. HttpRequest.Method returns HttpMethod; Create accepts it with URL/Uri and optional content. Exact spelling is available through Method.Method; value equality ignores ASCII case. CONNECT is representable but the socket transport does not implement tunnelling.

HTTP/1.1 admits 1 MiB buffered bodies and known-length uploads, 32 KiB headers and 100 fields, subject to independent host allocation budgets. Incoming requests support bounded chunked coding; client responses support up to 16 interim replies before the final response. Chunk extensions/trailers and status-101 upgrades remain unsupported. JSON has a separate 1 KiB bound. See the Web guide for exact ownership, limits and deferred hosting capabilities.

The 1 MiB admission ceiling is not a qualified transfer guarantee: the native stress-GC host currently exceeds its network deadline at that size. See the HTTP foundation evidence in docs/http-foundation.md for host budgets and validation limitations.

HttpServerOptions configures smaller request body/header limits and read/write budgets. Pass it to the four-argument HttpServer.Listen; validation occurs before binding and later option mutations do not affect the server. Existing defaults remain 1 MiB bodies, 32 KiB/100 headers and 15-second phase deadlines. Positive timeouts through 60 seconds are supported; no infinite deadline is admitted.

Development HttpServer.Serve(handler) owns bounded concurrent callback dispatch. Its task represents the server lifetime; applications do not await each request in an accept loop. See server-managed callbacks for outcome diagnostics, ownership and joined shutdown.

Media types (development)

MediaType.Parse provides immutable type/subtype, suffix and parameter structure. Use typed presets such as MediaTypes.Application.Json and MediaTypes.Text.Plain with the typed HTTP content constructors. Presets and formatted strings are cached; custom inputs are not globally interned. WithParameter returns a changed value, and equality preserves case-sensitive boundary/unknown parameter values.

HttpRequest.GetContentType() and HttpResponse.GetContentType() return Result<Optional<MediaType>, HttpError>: missing and malformed headers remain distinct. HttpContent.GetContentType() reads producer metadata. None of these reads consumes a body. Content-Type is a concrete media type, not an Accept range or quality weight. See the media type contract for limits.

Modules

2 items

Types

22 items
DelegatingHandler Base for middleware which forwards to an owned inner handler.
HttpClient Sends requests through an injected handler pipeline; defaults to HttpSocketHandler.
HttpCompletionOption Selects when HttpClient.Send completes. Body reads after headers need their own cancellation.
HttpContent Abstract HTTP body and content metadata with stream transfer and explicit ownership.
HttpContext Owns the combined lifetime of an accepted request and its outgoing response.
HttpError An expected failure while constructing or exchanging an HTTP message.
HttpHandler Base contract for a reusable request pipeline or terminal transport.
HttpHeader An HTTP header name and value. Socket parsing lowercases names and trims surrounding spaces/tabs from values.
HttpMemoryContent Buffered HTTP content retaining a readonly memory window without copying.
HttpMethod An immutable HTTP method token. Construction preserves spelling, including custom methods. Equality and hashing are ordinal-ignore-case, matching .NET HttpMethod.
HttpRequest An HTTP request with a validated HttpMethod and content; Create accepts predefined and custom methods. Factories validate the supported URL subset.
HttpResponse A disposable response with status, headers and buffered or streaming content; Respond configures status/content without I/O. Public construction supports fake/custom handlers.
HttpServer A bounded HTTP/1.1 server with manual acceptance, single-exchange callbacks and server-managed concurrent dispatch.
HttpServerOptions Configures buffered request admission and exchange deadlines.
HttpSocketHandler A bounded socket-backed HTTP/1.1 transport for predefined and custom method tokens; CONNECT tunnelling is unsupported. Each Send owns independent buffers and a connection.
HttpStatusCode Named HTTP status codes; unnamed numeric values remain representable.
HttpStreamContent One-shot HTTP content backed by an input stream.
HttpStringContent Buffered UTF-8 text content, using text/plain by default.
HttpVersion An immutable protocol version value. Representing a version does not enable transport support.
MediaType An immutable concrete HTTP media type with decoded parameters and value equality.
RouteMatch Captured, decoded values from a successful route match.
RoutePattern A reusable literal/single-segment parameter pattern, independent of dispatch.