Skip to content

Commit b80ad2a

Browse files
authored
Merge pull request #71 from WebAssembly/pch/fallible_finish
make outgoing-body.finish fallible in case of a Content-Length mismatch
2 parents e181913 + 11a9ca0 commit b80ad2a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

proxy.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,11 +1401,19 @@ will return error.</p>
14011401
called to signal that the response is complete. If the <a href="#outgoing_body"><code>outgoing-body</code></a>
14021402
is dropped without calling <code>outgoing-body.finalize</code>, the implementation
14031403
should treat the body as corrupted.</p>
1404+
<p>Fails if the body's <a href="#outgoing_request"><code>outgoing-request</code></a> or <a href="#outgoing_response"><code>outgoing-response</code></a> was
1405+
constructed with a Content-Length header, and the contents written
1406+
to the body (via <code>write</code>) does not match the value given in the
1407+
Content-Length.</p>
14041408
<h5>Params</h5>
14051409
<ul>
14061410
<li><a name="static_outgoing_body.finish.this"><code>this</code></a>: own&lt;<a href="#outgoing_body"><a href="#outgoing_body"><code>outgoing-body</code></a></a>&gt;</li>
14071411
<li><a name="static_outgoing_body.finish.trailers"><a href="#trailers"><code>trailers</code></a></a>: option&lt;own&lt;<a href="#trailers"><a href="#trailers"><code>trailers</code></a></a>&gt;&gt;</li>
14081412
</ul>
1413+
<h5>Return values</h5>
1414+
<ul>
1415+
<li><a name="static_outgoing_body.finish.0"></a> result&lt;_, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;</li>
1416+
</ul>
14091417
<h4><a name="method_future_incoming_response.subscribe"><code>[method]future-incoming-response.subscribe: func</code></a></h4>
14101418
<p>Returns a pollable which becomes ready when either the Response has
14111419
been received, or an error has occured. When this pollable is ready,

wit/types.wit

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,15 @@ interface types {
515515
/// called to signal that the response is complete. If the `outgoing-body`
516516
/// is dropped without calling `outgoing-body.finalize`, the implementation
517517
/// should treat the body as corrupted.
518-
finish: static func(this: outgoing-body, trailers: option<trailers>);
518+
///
519+
/// Fails if the body's `outgoing-request` or `outgoing-response` was
520+
/// constructed with a Content-Length header, and the contents written
521+
/// to the body (via `write`) does not match the value given in the
522+
/// Content-Length.
523+
finish: static func(
524+
this: outgoing-body,
525+
trailers: option<trailers>
526+
) -> result<_, error-code>;
519527
}
520528

521529
/// Represents a future which may eventaully return an incoming HTTP

0 commit comments

Comments
 (0)