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

Add take-headers methods for incoming messages and bump package version to 0.2.1-draft #103

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
32 changes: 28 additions & 4 deletions imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ It is intended to be <code>include</code>d in other worlds.</p>
<li>interface <a href="#wasi:cli_stderr_0.2.0"><code>wasi:cli/[email protected]</code></a></li>
<li>interface <a href="#wasi:cli_stdin_0.2.0"><code>wasi:cli/[email protected]</code></a></li>
<li>interface <a href="#wasi:clocks_monotonic_clock_0.2.0"><code>wasi:clocks/[email protected]</code></a></li>
<li>interface <a href="#wasi:http_types_0.2.0"><code>wasi:http/[email protected].0</code></a></li>
<li>interface <a href="#wasi:http_outgoing_handler_0.2.0"><code>wasi:http/[email protected].0</code></a></li>
<li>interface <a href="#wasi:http_types_0.2.1_draft"><code>wasi:http/[email protected].1-draft</code></a></li>
<li>interface <a href="#wasi:http_outgoing_handler_0.2.1_draft"><code>wasi:http/[email protected].1-draft</code></a></li>
<li>interface <a href="#wasi:clocks_wall_clock_0.2.0"><code>wasi:clocks/[email protected]</code></a></li>
</ul>
</li>
Expand Down Expand Up @@ -561,7 +561,7 @@ occured.</p>
<ul>
<li><a name="subscribe_duration.0"></a> own&lt;<a href="#pollable"><a href="#pollable"><code>pollable</code></a></a>&gt;</li>
</ul>
<h2><a name="wasi:http_types_0.2.0"></a>Import interface wasi:http/[email protected].0</h2>
<h2><a name="wasi:http_types_0.2.1_draft"></a>Import interface wasi:http/[email protected].1-draft</h2>
<p>This interface defines all of the types and methods for implementing
HTTP Requests and Responses, both incoming and outgoing, as well as
their headers, trailers, and bodies.</p>
Expand Down Expand Up @@ -971,6 +971,18 @@ the parent <a href="#incoming_request"><code>incoming-request</code></a> is drop
<ul>
<li><a name="method_incoming_request.headers.0"></a> own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;</li>
</ul>
<h4><a name="method_incoming_request.take_headers"></a><code>[method]incoming-request.take-headers: func</code></h4>
<p>Gives the <a href="#headers"><code>headers</code></a> associated with this request as an owned resource.
Will only return success at most once, and subsequent calls will return
error.</p>
<h5>Params</h5>
<ul>
<li><a name="method_incoming_request.take_headers.self"></a><code>self</code>: borrow&lt;<a href="#incoming_request"><a href="#incoming_request"><code>incoming-request</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a name="method_incoming_request.take_headers.0"></a> result&lt;own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;&gt;</li>
</ul>
<h4><a name="method_incoming_request.consume"></a><code>[method]incoming-request.consume: func</code></h4>
<p>Gives the <a href="#incoming_body"><code>incoming-body</code></a> associated with this request. Will only
return success at most once, and subsequent calls will return error.</p>
Expand Down Expand Up @@ -1248,6 +1260,18 @@ if called additional times.</p>
<ul>
<li><a name="method_incoming_response.consume.0"></a> result&lt;own&lt;<a href="#incoming_body"><a href="#incoming_body"><code>incoming-body</code></a></a>&gt;&gt;</li>
</ul>
<h4><a name="method_incoming_response.take_headers"></a><code>[method]incoming-response.take-headers: func</code></h4>
<p>Returns the <a href="#headers"><code>headers</code></a> associated with this response as an owned
resource. Will only return success at most once, and subsequent calls
will return error.</p>
<h5>Params</h5>
<ul>
<li><a name="method_incoming_response.take_headers.self"></a><code>self</code>: borrow&lt;<a href="#incoming_response"><a href="#incoming_response"><code>incoming-response</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a name="method_incoming_response.take_headers.0"></a> result&lt;own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;&gt;</li>
</ul>
<h4><a name="method_incoming_body.stream"></a><code>[method]incoming-body.stream: func</code></h4>
<p>Returns the contents of the body, as a stream of bytes.</p>
<p>Returns success on first call: the stream representing the contents
Expand Down Expand Up @@ -1447,7 +1471,7 @@ but those will be reported by the <a href="#incoming_body"><code>incoming-body</
<ul>
<li><a name="method_future_incoming_response.get.0"></a> option&lt;result&lt;result&lt;own&lt;<a href="#incoming_response"><a href="#incoming_response"><code>incoming-response</code></a></a>&gt;, <a href="#error_code"><a href="#error_code"><code>error-code</code></a></a>&gt;&gt;&gt;</li>
</ul>
<h2><a name="wasi:http_outgoing_handler_0.2.0"></a>Import interface wasi:http/[email protected].0</h2>
<h2><a name="wasi:http_outgoing_handler_0.2.1_draft"></a>Import interface wasi:http/[email protected].1-draft</h2>
<p>This interface defines a handler of outgoing HTTP Requests. It should be
imported by components which wish to make HTTP Requests.</p>
<hr />
Expand Down
36 changes: 30 additions & 6 deletions proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ outgoing HTTP requests.</p>
<li>interface <a href="#wasi:clocks_monotonic_clock_0.2.0"><code>wasi:clocks/[email protected]</code></a></li>
<li>interface <a href="#wasi:io_error_0.2.0"><code>wasi:io/[email protected]</code></a></li>
<li>interface <a href="#wasi:io_streams_0.2.0"><code>wasi:io/[email protected]</code></a></li>
<li>interface <a href="#wasi:http_types_0.2.0"><code>wasi:http/[email protected].0</code></a></li>
<li>interface <a href="#wasi:http_types_0.2.1_draft"><code>wasi:http/[email protected].1-draft</code></a></li>
<li>interface <a href="#wasi:random_random_0.2.0"><code>wasi:random/[email protected]</code></a></li>
<li>interface <a href="#wasi:cli_stdout_0.2.0"><code>wasi:cli/[email protected]</code></a></li>
<li>interface <a href="#wasi:cli_stderr_0.2.0"><code>wasi:cli/[email protected]</code></a></li>
<li>interface <a href="#wasi:cli_stdin_0.2.0"><code>wasi:cli/[email protected]</code></a></li>
<li>interface <a href="#wasi:http_outgoing_handler_0.2.0"><code>wasi:http/[email protected].0</code></a></li>
<li>interface <a href="#wasi:http_outgoing_handler_0.2.1_draft"><code>wasi:http/[email protected].1-draft</code></a></li>
<li>interface <a href="#wasi:clocks_wall_clock_0.2.0"><code>wasi:clocks/[email protected]</code></a></li>
</ul>
</li>
<li>Exports:
<ul>
<li>interface <a href="#wasi:http_incoming_handler_0.2.0"><code>wasi:http/[email protected].0</code></a></li>
<li>interface <a href="#wasi:http_incoming_handler_0.2.1_draft"><code>wasi:http/[email protected].1-draft</code></a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -496,7 +496,7 @@ is ready for reading, before performing the <code>splice</code>.</p>
<ul>
<li><a name="method_output_stream.blocking_splice.0"></a> result&lt;<code>u64</code>, <a href="#stream_error"><a href="#stream_error"><code>stream-error</code></a></a>&gt;</li>
</ul>
<h2><a name="wasi:http_types_0.2.0"></a>Import interface wasi:http/[email protected].0</h2>
<h2><a name="wasi:http_types_0.2.1_draft"></a>Import interface wasi:http/[email protected].1-draft</h2>
<p>This interface defines all of the types and methods for implementing
HTTP Requests and Responses, both incoming and outgoing, as well as
their headers, trailers, and bodies.</p>
Expand Down Expand Up @@ -906,6 +906,18 @@ the parent <a href="#incoming_request"><code>incoming-request</code></a> is drop
<ul>
<li><a name="method_incoming_request.headers.0"></a> own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;</li>
</ul>
<h4><a name="method_incoming_request.take_headers"></a><code>[method]incoming-request.take-headers: func</code></h4>
<p>Gives the <a href="#headers"><code>headers</code></a> associated with this request as an owned resource.
Will only return success at most once, and subsequent calls will return
error.</p>
<h5>Params</h5>
<ul>
<li><a name="method_incoming_request.take_headers.self"></a><code>self</code>: borrow&lt;<a href="#incoming_request"><a href="#incoming_request"><code>incoming-request</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a name="method_incoming_request.take_headers.0"></a> result&lt;own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;&gt;</li>
</ul>
<h4><a name="method_incoming_request.consume"></a><code>[method]incoming-request.consume: func</code></h4>
<p>Gives the <a href="#incoming_body"><code>incoming-body</code></a> associated with this request. Will only
return success at most once, and subsequent calls will return error.</p>
Expand Down Expand Up @@ -1183,6 +1195,18 @@ if called additional times.</p>
<ul>
<li><a name="method_incoming_response.consume.0"></a> result&lt;own&lt;<a href="#incoming_body"><a href="#incoming_body"><code>incoming-body</code></a></a>&gt;&gt;</li>
</ul>
<h4><a name="method_incoming_response.take_headers"></a><code>[method]incoming-response.take-headers: func</code></h4>
<p>Returns the <a href="#headers"><code>headers</code></a> associated with this response as an owned
resource. Will only return success at most once, and subsequent calls
will return error.</p>
<h5>Params</h5>
<ul>
<li><a name="method_incoming_response.take_headers.self"></a><code>self</code>: borrow&lt;<a href="#incoming_response"><a href="#incoming_response"><code>incoming-response</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a name="method_incoming_response.take_headers.0"></a> result&lt;own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;&gt;</li>
</ul>
<h4><a name="method_incoming_body.stream"></a><code>[method]incoming-body.stream: func</code></h4>
<p>Returns the contents of the body, as a stream of bytes.</p>
<p>Returns success on first call: the stream representing the contents
Expand Down Expand Up @@ -1454,7 +1478,7 @@ represented as a <code>u64</code>.</p>
<ul>
<li><a name="get_stdin.0"></a> own&lt;<a href="#input_stream"><a href="#input_stream"><code>input-stream</code></a></a>&gt;</li>
</ul>
<h2><a name="wasi:http_outgoing_handler_0.2.0"></a>Import interface wasi:http/[email protected].0</h2>
<h2><a name="wasi:http_outgoing_handler_0.2.1_draft"></a>Import interface wasi:http/[email protected].1-draft</h2>
<p>This interface defines a handler of outgoing HTTP Requests. It should be
imported by components which wish to make HTTP Requests.</p>
<hr />
Expand Down Expand Up @@ -1532,7 +1556,7 @@ also known as <a href="https://en.wikipedia.org/wiki/Unix_time">Unix Time</a>.</
<ul>
<li><a name="resolution.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
</ul>
<h2><a name="wasi:http_incoming_handler_0.2.0"></a>Export interface wasi:http/[email protected].0</h2>
<h2><a name="wasi:http_incoming_handler_0.2.1_draft"></a>Export interface wasi:http/[email protected].1-draft</h2>
<hr />
<h3>Types</h3>
<h4><a name="incoming_request"></a><code>type incoming-request</code></h4>
Expand Down
2 changes: 1 addition & 1 deletion wit/proxy.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:[email protected].0;
package wasi:[email protected].1-draft;

/// The `wasi:http/imports` world imports all the APIs for HTTP proxies.
/// It is intended to be `include`d in other worlds.
Expand Down
10 changes: 10 additions & 0 deletions wit/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ interface types {
/// `incoming-request` before all children are dropped will trap.
headers: func() -> headers;

/// Gives the `headers` associated with this request as an owned resource.
/// Will only return success at most once, and subsequent calls will return
/// error.
take-headers: func() -> result<headers>;

/// Gives the `incoming-body` associated with this request. Will only
/// return success at most once, and subsequent calls will return error.
consume: func() -> result<incoming-body>;
Expand Down Expand Up @@ -392,6 +397,11 @@ interface types {
/// Returns the incoming body. May be called at most once. Returns error
/// if called additional times.
consume: func() -> result<incoming-body>;

/// Returns the `headers` associated with this response as an owned
/// resource. Will only return success at most once, and subsequent calls
/// will return error.
take-headers: func() -> result<headers>;
}

/// Represents an incoming HTTP Request or Response's Body.
Expand Down
Loading