Skip to main content

Module http

Module http 

Source
Expand description

The HTTP seam behind fetch() / http(): the HttpClient trait and its request and response types, plus the HttpDispatch trait that decides who runs a request. lumen-http-ureq is the client Lumen ships. The HTTP seam behind the scripts’ fetch(url, tag) and http(#{...}) builtins.

HttpClient is the transport contract: one blocking call that turns an HttpRequest into an HttpResponse, with a byte cap on the body it buffers. The client Lumen ships is lumen-http-ureq, selected by the default-on http-fetch feature. An embedder that needs a different stack (a proxy-aware client, a recording client in tests, an in-process fake) implements the trait and installs it with FetchRegistry::with_client before the script plugin builds.

HttpDispatch is the concurrency contract next to it: who runs the request and how its reply gets back. ThreadDispatch is the one every desktop build uses, a worker thread per request blocked in HttpClient::send. A platform with no threads to block supplies its own and installs it with FetchRegistry::with_dispatch; in a browser that is lumen-web-http, which runs the request on the page’s own fetch and needs no client behind it.

HttpHook is how a plugin takes part in every request without replacing either: it adjusts a request just before it is dispatched and reads each reply before the script does. The hooks live in HttpHooks, apart from the registry, so they survive a client being swapped.

The types are transport-only on purpose: the delivery tag, the fetch()-versus-http() reply style, and the retry or logging policy all stay on the runtime side of the seam, so a client implementation never has to know what a script is.

Structs§

DisabledHttpClient
The client a build without the http-fetch feature gets: every request resolves to an error carrying the rebuild hint, so a size-trimmed binary says why fetch() did nothing instead of silently dropping it.
HttpRequest
A request handed to a client on a per-request worker thread. Method, url, headers, and body in: the input half of the Qt QNetworkRequest shape.
HttpResponse
The reply half of the Qt QNetworkReply shape: status, headers, and body out.
ThreadDispatch
The dispatcher every desktop build runs: one worker thread per request, blocked in HttpClient::send until the reply lands.
UnknownCredentials
A credentials value that is none of the three web fetch names.

Enums§

Credentials
Which requests carry credentials (cookies, HTTP authentication, client certificates), with the meaning web fetch gives its credentials option.

Traits§

HttpClient
The transport a script’s HTTP builtins run on.
HttpDispatch
How a request leaves the calling thread and how its reply comes back.
HttpHook
Something that takes part in every HTTP exchange a script starts, whichever client and dispatcher carry it.

Type Aliases§

HttpDone
The completion callback a dispatcher owns for the life of one request. It is called exactly once, from whatever thread or task the reply arrived on, and it never touches the world: all it does is hand the outcome to the channel the world thread drains.