Wasm Directoryalpha
Resource

incoming-body

Represents an incoming HTTP Request or Response's Body.

resource incoming-body;

F stream

stream: func() -> result​<input-stream, _>;

Returns the contents of the body, as a stream of bytes.

Returns success on first call: the stream representing the contents can be retrieved at most once. Subsequent calls will return error.

The returned input-stream resource is a child: it must be dropped before the parent incoming-body is dropped, or consumed by incoming-body.finish.

This invariant ensures that the implementation can determine whether the user is consuming the contents of the body, waiting on the future-trailers to be ready, or neither. This allows for network backpressure is to be applied when the user is consuming the body, and for that backpressure to not inhibit delivery of the trailers if the user does not read the entire body.

F finish

finish: func(this: incoming-body) -> future-trailers;

Takes ownership of incoming-body, and returns a future-trailers. This function will trap if the input-stream child is still alive.