Skip to main content

Module http

Module http 

Source
Expand description

HTTP from a guest. The worker makes the request on the guest’s behalf, under the invocation’s egress policy: which hosts it may reach and which credential headers ride along to which origins. A file body or a file response moves between the socket and the volume without passing through guest memory.

§ABI

The import module subako_http holds two functions:

  • request(ptr: i32, len: i32) -> i32 reads len bytes at ptr as a Request in JSON, performs it, and holds the answer. It returns the answer’s length in bytes.
  • read_response(ptr: i32, len: i32) -> i32 copies the held answer to ptr, where len must be the length request returned, and forgets it. It returns 0.

The answer is Answer in JSON: {"ok": Response} or {"error": HttpError}. A negative return is a misuse of the ABI itself: ABI_OUT_OF_BOUNDS, ABI_NOTHING_HELD, or ABI_LENGTH_MISMATCH.

Structs§

HttpError
Why a request produced no response.
Request
One HTTP request. The schemars descriptions are what a model reads when the http package serves this as its input.
Response
The final hop’s response.

Enums§

Answer
What request holds for read_response.
HttpErrorKind
Method
The methods a request may use. CONNECT, TRACE, and TRACK have no variant: the first asks for a tunnel, and the others echo the request, credential headers included, back to the guest.
RequestBody
ResponseBody
ResponseOutput
Where the response body goes.

Constants§

ABI_LENGTH_MISMATCH
read_response’s length is not the answer’s.
ABI_NOTHING_HELD
read_response ran with no answer held.
ABI_OUT_OF_BOUNDS
The guest’s memory range lies outside its memory.
INLINE_MAX_BYTES
The largest response body returned inline, in bytes.
MAX_REDIRECTS
The most redirects one request follows.
REQUEST_MAX_BYTES
The largest request JSON the worker reads from guest memory, in bytes. A larger body travels as a file.

Functions§

request
Performs request through the worker.