WasiHttp
12 types23 functionsThe component target's HTTP server: serve runs an Http handler as a
wasi:http/incoming-handler export, over the wasi:http/types views below.
Every handle is dropped explicitly, a child before its parent.
At a glance
Types
@Fields
The fields resource of wasi:http/types@0.2.3, as a handle. It comes only
from the functions here that return one. Release it with
dropFields.
@IncomingRequest
The incoming-request resource of wasi:http/types@0.2.3, as a handle. It
comes only from the functions here that return one. Release it with
dropIncomingRequest.
@ResponseOutparam
The response-outparam resource of wasi:http/types@0.2.3, as a handle. It
comes only from the functions here that return one. Release it with
dropResponseOutparam.
@IncomingBody
The incoming-body resource of wasi:http/types@0.2.3, as a handle. It
comes only from the functions here that return one. Release it with
dropIncomingBody.
@OutgoingResponse
The outgoing-response resource of wasi:http/types@0.2.3, as a handle. It
comes only from the functions here that return one. Release it with
dropOutgoingResponse.
@OutgoingBody
The outgoing-body resource of wasi:http/types@0.2.3, as a handle. It
comes only from the functions here that return one. Release it with
dropOutgoingBody.
Scheme
The view of WIT's scheme type, from wasi:http/types@0.2.3.
HeaderError
The view of WIT's header-error type, from wasi:http/types@0.2.3.
ErrorCode
The view of WIT's error-code type, from wasi:http/types@0.2.3.
DNSErrorPayload
The view of WIT's DNS-error-payload type, from wasi:http/types@0.2.3.
TLSAlertReceivedPayload
The view of WIT's TLS-alert-received-payload type, from
wasi:http/types@0.2.3.
FieldSizePayload
The view of WIT's field-size-payload type, from wasi:http/types@0.2.3.
Functions
serve
Read the request, run handler on it, and answer with what it returns. The
response is handed to the host before its body is written: the host sends
the body as it is written, so a body larger than the stream's buffer would
otherwise never drain.
The request's headers are every header the host passes on, in the order it lists them, names lowercase and a header sent twice as two entries.
The whole request body is read into memory before the handler runs, and a
body that arrives in more than one read is held twice while its pieces are
joined. With the default 1 MiB of memory that caps a request body at about
half of it, 500 KB; past it the instance runs out of memory and the host
answers 500. Building with --memory raises the cap.
A status the host refuses, such as one below 100, answers 500; one outside
0 … 65535 traps, and the host answers 500 for it. A header the host
refuses, a forbidden one such as connection or one whose name or value is
not valid header syntax, is left out. So is a content-length the handler
sets: the host frames the body itself, and a length that disagreed with the
body would cut it short or break the response.
newFields
WIT's fields constructor, from wasi:http/types@0.2.3, in Bert's view of
its types.
fieldsEntries
WIT's fields.entries method, from wasi:http/types@0.2.3, in Bert's view
of its types.
fieldsAppend
WIT's fields.append method, from wasi:http/types@0.2.3, in Bert's view
of its types.
incomingRequestMethod
WIT's incoming-request.method method, from wasi:http/types@0.2.3, in
Bert's view of its types.
incomingRequestPathWithQuery
WIT's incoming-request.path-with-query method, from
wasi:http/types@0.2.3, in Bert's view of its types.
incomingRequestScheme
WIT's incoming-request.scheme method, from wasi:http/types@0.2.3, in
Bert's view of its types.
incomingRequestAuthority
WIT's incoming-request.authority method, from wasi:http/types@0.2.3, in
Bert's view of its types.
incomingRequestHeaders
WIT's incoming-request.headers method, from wasi:http/types@0.2.3, in
Bert's view of its types.
incomingRequestConsume
WIT's incoming-request.consume method, from wasi:http/types@0.2.3, in
Bert's view of its types.
responseOutparamSet
WIT's response-outparam.set static function, from wasi:http/types@0.2.3,
in Bert's view of its types.
incomingBodyStream
WIT's incoming-body.stream method, from wasi:http/types@0.2.3, in Bert's
view of its types.
newOutgoingResponse
WIT's outgoing-response constructor, from wasi:http/types@0.2.3, in
Bert's view of its types.
outgoingResponseSetStatusCode
A status outside 0 … 65535 traps; one the host refuses is an Err.
outgoingResponseBody
WIT's outgoing-response.body method, from wasi:http/types@0.2.3, in
Bert's view of its types.
outgoingBodyWrite
WIT's outgoing-body.write method, from wasi:http/types@0.2.3, in Bert's
view of its types.
outgoingBodyFinish
WIT's outgoing-body.finish static function, from wasi:http/types@0.2.3,
in Bert's view of its types.
dropFields
Drops the fields handle, from wasi:http/types@0.2.3. Nothing else
releases it, and the handle is not used after.
dropIncomingRequest
Drops the incoming-request handle, from wasi:http/types@0.2.3. Nothing
else releases it, and the handle is not used after.
dropResponseOutparam
Drops the response-outparam handle, from wasi:http/types@0.2.3. Nothing
else releases it, and the handle is not used after.
dropIncomingBody
Drops the incoming-body handle, from wasi:http/types@0.2.3. Nothing else
releases it, and the handle is not used after.
dropOutgoingResponse
Drops the outgoing-response handle, from wasi:http/types@0.2.3. Nothing
else releases it, and the handle is not used after.
dropOutgoingBody
Drops the outgoing-body handle, from wasi:http/types@0.2.3. Nothing else
releases it, and the handle is not used after.