Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow independent retrieval of trailers #154

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions wit-0.3.0-draft/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,27 @@ interface types {
/// trailers at any given time.
resource body {

/// Construct a new `body` with the specified stream.
///
/// This function returns a future, which will resolve
/// to an error code if transmitting stream data fails.
///
/// The returned future resolves to success once body stream
/// is fully transmitted.
new: static func(
%stream: stream<u8>,
) -> tuple<body, future<result<_, error-code>>>;

/// Construct a new `body` with the specified stream and trailers.
///
/// This function returns a future, which will resolve
/// to an error code if transmitting stream data or trailers fails.
///
/// The returned future resolves to success once body stream and trailers
/// are fully transmitted.
new: static func(
new-with-trailers: static func(
%stream: stream<u8>,
trailers: option<future<trailers>>
trailers: future<trailers>
) -> tuple<body, future<result<_, error-code>>>;

/// Returns the contents of the body, as a stream of bytes.
Expand All @@ -260,9 +273,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<trailers>;
}

/// Represents an HTTP Request.
Expand Down