Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit 2995fe0

Browse files
committed
p3: allow multiple active body refs to exist, drop into-parts
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent 55db2ff commit 2995fe0

1 file changed

Lines changed: 7 additions & 42 deletions

File tree

wit-0.3.0-draft/types.wit

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ interface types {
284284

285285
/// Takes ownership of `body`, and returns an unresolved optional `trailers` result.
286286
///
287-
/// If this function is called while either a stream or future returned by a previous
288-
/// call to `body.stream` is still open, this function will return an error.
287+
/// This function will return an error if it is called while either:
288+
/// - a stream or future returned by a previous call to `body.stream` is still open
289+
/// - `finish` was already called on another instance of this `body` resource
289290
finish: static func(this: body) -> result<future<result<option<trailers>, error-code>>>;
290291
}
291292

@@ -366,27 +367,9 @@ interface types {
366367
/// the parent `request` is dropped, or its ownership is transferred
367368
/// to another component by e.g. `handler.handle`.
368369
///
369-
/// Only a single body resource can be active at a time.
370-
/// If this method is called before the body resource returned by
371-
/// a previous call to this method is dropped, error will be returned.
372-
///
373370
/// Once `body.finish` is called on a body returned by this method,
374-
/// all subsequent calls to this method will return `ok(none)`.
375-
body: func() -> result<option<body>>;
376-
377-
/// Takes ownership of the `request` and returns the `headers`, `body`
378-
/// and `request-options`, if any.
379-
///
380-
/// The headers returned by this function are considered to be a clone of the headers
381-
/// of the request. Changes to the `headers` returned by this function will not be reflected
382-
/// in the immutable `headers` resources, that could have been acquired by calls to `headers`
383-
/// prior to this method being called.
384-
///
385-
/// If a body child exists when this function is called, an error will be returned.
386-
///
387-
/// Once `body.finish` is called on a body returned by a previous
388-
/// call to `body` method, this method returns body as `none`.
389-
into-parts: static func(this: request) -> tuple<headers, option<body>, option<request-options>>;
371+
/// all subsequent calls to this method will return `none`.
372+
body: func() -> option<body>;
390373
}
391374

392375
/// Parameters for making an HTTP Request. Each of these parameters is
@@ -462,26 +445,8 @@ interface types {
462445
/// the parent `response` is dropped, or its ownership is transferred
463446
/// to another component by e.g. `handler.handle`.
464447
///
465-
/// Only a single body resource can be active at a time.
466-
/// If this method is called before the body resource returned by
467-
/// a previous call to this method is dropped, error will be returned.
468-
///
469448
/// Once `body.finish` is called on a body returned by this method,
470-
/// all subsequent calls to this method will return `ok(none)`.
471-
body: func() -> result<option<body>>;
472-
473-
/// Takes ownership of the `response` and returns the `headers` and `body`,
474-
/// if any.
475-
///
476-
/// The headers returned by this function are considered to be a clone of the headers
477-
/// of the response. Changes to the `headers` returned by this function will not be reflected
478-
/// in the immutable `headers` resources, that could have been acquired by calls to `headers`
479-
/// prior to this method being called.
480-
///
481-
/// If a body child exists when this function is called, an error will be returned.
482-
///
483-
/// Once `body.finish` is called on a body returned by a previous
484-
/// call to `body` method, this method returns body as `none`.
485-
into-parts: static func(this: response) -> result<tuple<headers, option<body>>>;
449+
/// all subsequent calls to this method will return `none`.
450+
body: func() -> option<body>;
486451
}
487452
}

0 commit comments

Comments
 (0)