|
2 | 2 | /// Requests and Responses, as well as their headers, trailers, and bodies.
|
3 | 3 | interface types {
|
4 | 4 | use wasi:clocks/monotonic-clock@0.2.3.{duration};
|
5 |
| - use wasi:io/error@0.2.3.{error}; |
6 | 5 |
|
7 | 6 | /// This type corresponds to HTTP standard Methods.
|
8 | 7 | variant method {
|
@@ -92,18 +91,6 @@ interface types {
|
92 | 91 | field-size: option<u32>
|
93 | 92 | }
|
94 | 93 |
|
95 |
| - /// Attempts to extract a http-related `error-code` from the stream `error` |
96 |
| - /// provided. |
97 |
| - /// |
98 |
| - /// Stream operations may fail with a stream `error` with more information |
99 |
| - /// about the operation that failed. This `error` can be passed to this |
100 |
| - /// function to see if there's http-related information about the error to |
101 |
| - /// return. |
102 |
| - /// |
103 |
| - /// Note that this function is fallible because not all stream errors are |
104 |
| - /// http-related errors. |
105 |
| - http-error-code: func(err: borrow<error>) -> option<error-code>; |
106 |
| - |
107 | 94 | /// This type enumerates the different kinds of errors that may occur when
|
108 | 95 | /// setting or appending to a `fields` resource.
|
109 | 96 | variant header-error {
|
@@ -254,16 +241,24 @@ interface types {
|
254 | 241 | resource body {
|
255 | 242 |
|
256 | 243 | /// Construct a new `body` with the specified stream and trailers.
|
257 |
| - constructor( |
| 244 | + /// This function returns a future, which will resolve |
| 245 | + /// to an error code if transmitting stream data or trailers fails. |
| 246 | + /// The returned future resolves to success once body stream and trailers |
| 247 | + /// are fully transmitted. |
| 248 | + new: static func( |
258 | 249 | %stream: stream<u8>,
|
259 | 250 | trailers: option<future<trailers>>
|
260 |
| - ); |
| 251 | + ) -> tuple<body, future<result<_, error-code>>>; |
261 | 252 |
|
262 | 253 | /// Returns the contents of the body, as a stream of bytes.
|
263 | 254 | ///
|
264 | 255 | /// This function may be called multiple times as long as any `stream`s
|
265 | 256 | /// returned by previous calls have been dropped first.
|
266 |
| - %stream: func() -> result<stream<u8>>; |
| 257 | + /// |
| 258 | + /// On success, this function returns a stream and a future, which will resolve |
| 259 | + /// to an error code if receiving data from stream fails. |
| 260 | + /// The returned future resolves to success if body is closed. |
| 261 | + %stream: func() -> result<tuple<stream<u8>>, future<result<_, error-code>>>; |
267 | 262 |
|
268 | 263 | /// Takes ownership of `body`, and returns a `trailers`. This function will
|
269 | 264 | /// trap if a `stream` child is still alive.
|
|
0 commit comments