Skip to content

Commit

Permalink
feat: allow independent retrieval of trailers
Browse files Browse the repository at this point in the history
This commit changes wasi:http/types#body.finish to forward the
optionally present trailers, rather than retrieve them with the
possibility of generating an error along the way.

With this change, callers of `body.finish` will have to retreive
trailers on their own, which *may* produce an efficiency gain in the
case where trailers are present but not needed, and avoiding work of
checking for trailers in the first place.

Signed-off-by: Victor Adossi <[email protected]>
  • Loading branch information
vados-cosmonic committed Feb 19, 2025
1 parent 19b48d5 commit beed353
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions wit-0.3.0-draft/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ interface types {
/// are fully transmitted.
new: static func(
%stream: stream<u8>,
trailers: option<future<trailers>>
trailers: future<option<trailers>>
) -> tuple<body, future<result<_, error-code>>>;

/// Returns the contents of the body, as a stream of bytes.
Expand All @@ -260,9 +260,10 @@ interface types {
/// The returned future resolves to success if body is closed.
%stream: func() -> result<tuple<stream<u8>>, future<result<_, error-code>>>;

/// Takes ownership of `body`, and returns a `trailers`. This function will
/// trap if a `stream` child is still alive.
finish: static func(this: body) -> result<option<trailers>, error-code>;
/// Takes ownership of `body`, and returns an unresolved optional `trailers`.
///
/// This function will trap if a `stream` child is still alive.
finish: static func(this: body) -> future<option<trailers>>;
}

/// Represents an HTTP Request.
Expand Down

0 comments on commit beed353

Please sign in to comment.