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) -> i32readslenbytes atptras aRequestin JSON, performs it, and holds the answer. It returns the answer’s length in bytes.read_response(ptr: i32, len: i32) -> i32copies the held answer toptr, wherelenmust be the lengthrequestreturned, 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§
- Http
Error - Why a request produced no response.
- Request
- One HTTP request. The
schemarsdescriptions are what a model reads when thehttppackage serves this as its input. - Response
- The final hop’s response.
Enums§
- Answer
- What
requestholds forread_response. - Http
Error Kind - 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.
- Request
Body - Response
Body - Response
Output - Where the response body goes.
Constants§
- ABI_
LENGTH_ MISMATCH read_response’s length is not the answer’s.- ABI_
NOTHING_ HELD read_responseran 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
requestthrough the worker.