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

API Browser

Class

HttpServer

class HttpServer

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

Inheritance: Object → HttpServer

A bounded HTTP/1.1 server with manual acceptance, single-exchange callbacks and server-managed concurrent dispatch.

Remarks

Accept and AcceptHeaders transfer context ownership to the caller. ServeOne owns one complete exchange; Serve owns up to 16 concurrent exchanges and returns a server-lifetime task. HTTP framing and body/header limits follow HttpServerOptions; TLS is configured through its SslOptions. Responses close the connection; keep-alive is not implemented. Close closes connections immediately. The Serve lifetime then joins started handlers and disposes late responses. See the HTTP server lifetime reference for errors, cancellation and ownership.

Properties

3 items
CompletedRequests: long Successful responses completed by Serve; excludes explicit Accept/ServeOne calls.
FailedRequests: long Failed Serve exchanges, excluding cancellation caused by server shutdown.
LastRequestError: Optional<HttpError> Most recent Serve request error; None before any failure.

Methods

13 items
Accept(cancellationToken?: CancellationToken) -> Task<Result<HttpContext, HttpError>> Accepts request headers, transferring the exchange and unread body to the caller. Cancellation covers acceptance and headers; pass a token to later body reads.
AcceptHeaders(cancellationToken?: CancellationToken) -> Task<Result<HttpContext, HttpError>> Returns after valid headers; the caller reads Request.Content's stream on demand. Cancellation covers acceptance and headers. Pass a token to later body reads.
Close() -> () Stops acceptance and closes all owned exchanges. Idempotent; does not drain handlers.
Equals(other: object?) -> bool Tests reference identity by default; an ordinary class may override equality. Inherited from Object.Equals
GetHashCode() -> int Returns a stable identity hash by default; an ordinary class may override it consistently with equality. Inherited from Object.GetHashCode
GetLocalPort() -> Result<int, HttpError> Returns the listener's bound port.
GetType() -> TypeInfo Returns metadata for the concrete runtime type of this instance. Inherited from Object.GetType
Static member: Listen(address: string, port: int, backlog: int, options: HttpServerOptions) -> Result<HttpServer, HttpError> Validates and snapshots options before opening the listener.
Static member: Listen(address: string, port: int, backlog: int) -> Result<HttpServer, HttpError> Binds a TCP listener for bounded HTTP exchanges.
Serve(handler: (HttpContext) -> Task<Result<void, HttpError>>, cancellationToken?: CancellationToken) -> Task<Result<void, HttpError>> Starts server-managed concurrent request handling. The returned task represents server lifetime. Up to 16 exchanges run concurrently; request failures are recorded and do not stop…
Serve(handler: (HttpRequest) -> Task<Result<HttpResponse, HttpError>>, cancellationToken?: CancellationToken) -> Task<Result<void, HttpError>> Starts server-managed concurrent request handling. The returned task represents server lifetime. Up to 16 exchanges run concurrently; request failures are recorded and do not stop…
ServeOne(handler: (HttpRequest) -> Task<Result<HttpResponse, HttpError>>, cancellationToken?: CancellationToken) -> Task<Result<void, HttpError>> Handles one accepted context and sends the callback's buffered or known-length stream response. Cancellation ends this exchange, including an outstanding handler wait.
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