Skip to content

Commit 1098170

Browse files
author
Pat Hickey
committed
generate markdown
1 parent 4edaaae commit 1098170

File tree

1 file changed

+98
-21
lines changed

1 file changed

+98
-21
lines changed

proxy.md

Lines changed: 98 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ outgoing HTTP requests.</p>
1010
<li>interface <a href="#wasi:io_error_0.2.0_rc_2023_11_10"><code>wasi:io/error@0.2.0-rc-2023-11-10</code></a></li>
1111
<li>interface <a href="#wasi:io_poll_0.2.0_rc_2023_11_10"><code>wasi:io/poll@0.2.0-rc-2023-11-10</code></a></li>
1212
<li>interface <a href="#wasi:io_streams_0.2.0_rc_2023_11_10"><code>wasi:io/streams@0.2.0-rc-2023-11-10</code></a></li>
13-
<li>interface <a href="#wasi:cli_stdout_0.2.0_rc_2023_11_10"><code>wasi:cli/stdout@0.2.0-rc-2023-11-10</code></a></li>
14-
<li>interface <a href="#wasi:cli_stderr_0.2.0_rc_2023_11_10"><code>wasi:cli/stderr@0.2.0-rc-2023-11-10</code></a></li>
15-
<li>interface <a href="#wasi:cli_stdin_0.2.0_rc_2023_11_10"><code>wasi:cli/stdin@0.2.0-rc-2023-11-10</code></a></li>
13+
<li>interface <a href="#wasi:cli_stdout_0.2.0_rc_2023_12_05"><code>wasi:cli/stdout@0.2.0-rc-2023-12-05</code></a></li>
14+
<li>interface <a href="#wasi:cli_stderr_0.2.0_rc_2023_12_05"><code>wasi:cli/stderr@0.2.0-rc-2023-12-05</code></a></li>
15+
<li>interface <a href="#wasi:cli_stdin_0.2.0_rc_2023_12_05"><code>wasi:cli/stdin@0.2.0-rc-2023-12-05</code></a></li>
1616
<li>interface <a href="#wasi:clocks_monotonic_clock_0.2.0_rc_2023_11_10"><code>wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10</code></a></li>
17-
<li>interface <a href="#wasi:http_types_0.2.0_rc_2023_11_10"><code>wasi:http/types@0.2.0-rc-2023-11-10</code></a></li>
18-
<li>interface <a href="#wasi:http_outgoing_handler_0.2.0_rc_2023_11_10"><code>wasi:http/outgoing-handler@0.2.0-rc-2023-11-10</code></a></li>
17+
<li>interface <a href="#wasi:http_types_0.2.0_rc_2023_12_05"><code>wasi:http/types@0.2.0-rc-2023-12-05</code></a></li>
18+
<li>interface <a href="#wasi:http_outgoing_handler_0.2.0_rc_2023_12_05"><code>wasi:http/outgoing-handler@0.2.0-rc-2023-12-05</code></a></li>
1919
<li>interface <a href="#wasi:clocks_wall_clock_0.2.0_rc_2023_11_10"><code>wasi:clocks/wall-clock@0.2.0-rc-2023-11-10</code></a></li>
2020
</ul>
2121
</li>
2222
<li>Exports:
2323
<ul>
24-
<li>interface <a href="#wasi:http_incoming_handler_0.2.0_rc_2023_11_10"><code>wasi:http/incoming-handler@0.2.0-rc-2023-11-10</code></a></li>
24+
<li>interface <a href="#wasi:http_incoming_handler_0.2.0_rc_2023_12_05"><code>wasi:http/incoming-handler@0.2.0-rc-2023-12-05</code></a></li>
2525
</ul>
2626
</li>
2727
</ul>
@@ -62,7 +62,21 @@ represented as a <code>u64</code>.</p>
6262
<hr />
6363
<h3>Types</h3>
6464
<h4><a name="error"><code>resource error</code></a></h4>
65-
<hr />
65+
<p>A resource which represents some error information.</p>
66+
<p>The only method provided by this resource is <code>to-debug-string</code>,
67+
which provides some human-readable information about the error.</p>
68+
<p>In the <code>wasi:io</code> package, this resource is returned through the
69+
<code>wasi:io/streams/stream-error</code> type.</p>
70+
<p>To provide more specific error information, other interfaces may
71+
provide functions to further &quot;downcast&quot; this error into more specific
72+
error information. For example, <a href="#error"><code>error</code></a>s returned in streams derived
73+
from filesystem types to be described using the filesystem's own
74+
error-code type, using the function
75+
<code>wasi:filesystem/types/filesystem-error-code</code>, which takes a parameter
76+
<code>borrow&lt;error&gt;</code> and returns
77+
<code>option&lt;wasi:filesystem/types/error-code&gt;</code>.</p>
78+
<h2>The set of functions which can &quot;downcast&quot; an <a href="#error"><code>error</code></a> into a more
79+
concrete type is open.</h2>
6680
<h3>Functions</h3>
6781
<h4><a name="method_error.to_debug_string"><code>[method]error.to-debug-string: func</code></a></h4>
6882
<p>Returns a string that is suitable to assist humans in debugging
@@ -85,7 +99,7 @@ at once.</p>
8599
<hr />
86100
<h3>Types</h3>
87101
<h4><a name="pollable"><code>resource pollable</code></a></h4>
88-
<hr />
102+
<h2><a href="#pollable"><code>pollable</code></a> represents a single I/O event which may be ready, or not.</h2>
89103
<h3>Functions</h3>
90104
<h4><a name="method_pollable.ready"><code>[method]pollable.ready: func</code></a></h4>
91105
<p>Return the readiness of a pollable. This function never blocks.</p>
@@ -159,8 +173,21 @@ future operations.
159173
</li>
160174
</ul>
161175
<h4><a name="input_stream"><code>resource input-stream</code></a></h4>
176+
<p>An input bytestream.</p>
177+
<p><a href="#input_stream"><code>input-stream</code></a>s are <em>non-blocking</em> to the extent practical on underlying
178+
platforms. I/O operations always return promptly; if fewer bytes are
179+
promptly available than requested, they return the number of bytes promptly
180+
available, which could even be zero. To wait for data to be available,
181+
use the <code>subscribe</code> function to obtain a <a href="#pollable"><code>pollable</code></a> which can be polled
182+
for using <code>wasi:io/poll</code>.</p>
162183
<h4><a name="output_stream"><code>resource output-stream</code></a></h4>
163-
<hr />
184+
<p>An output bytestream.</p>
185+
<h2><a href="#output_stream"><code>output-stream</code></a>s are <em>non-blocking</em> to the extent practical on
186+
underlying platforms. Except where specified otherwise, I/O operations also
187+
always return promptly, after the number of bytes that can be written
188+
promptly, which could even be zero. To wait for the stream to be ready to
189+
accept data, the <code>subscribe</code> function to obtain a <a href="#pollable"><code>pollable</code></a> which can be
190+
polled for using <code>wasi:io/poll</code>.</h2>
164191
<h3>Functions</h3>
165192
<h4><a name="method_input_stream.read"><code>[method]input-stream.read: func</code></a></h4>
166193
<p>Perform a non-blocking read from the stream.</p>
@@ -281,7 +308,7 @@ following pseudo-code:</p>
281308
<pre><code class="language-text">let pollable = this.subscribe();
282309
while !contents.is_empty() {
283310
// Wait for the stream to become writable
284-
poll-one(pollable);
311+
pollable.block();
285312
let Ok(n) = this.check-write(); // eliding error handling
286313
let len = min(n, contents.len());
287314
let (chunk, rest) = contents.split_at(len);
@@ -290,7 +317,7 @@ while !contents.is_empty() {
290317
}
291318
this.flush();
292319
// Wait for completion of `flush`
293-
poll-one(pollable);
320+
pollable.block();
294321
// Check for any errors that arose during `flush`
295322
let _ = this.check-write(); // eliding error handling
296323
</code></pre>
@@ -350,7 +377,7 @@ all derived <a href="#pollable"><code>pollable</code></a>s created with this fun
350377
</ul>
351378
<h4><a name="method_output_stream.write_zeroes"><code>[method]output-stream.write-zeroes: func</code></a></h4>
352379
<p>Write zeroes to a stream.</p>
353-
<p>this should be used precisely like <code>write</code> with the exact same
380+
<p>This should be used precisely like <code>write</code> with the exact same
354381
preconditions (must use check-write first), but instead of
355382
passing a list of bytes, you simply pass the number of zero-bytes
356383
that should be written.</p>
@@ -373,15 +400,15 @@ the following pseudo-code:</p>
373400
<pre><code class="language-text">let pollable = this.subscribe();
374401
while num_zeroes != 0 {
375402
// Wait for the stream to become writable
376-
poll-one(pollable);
403+
pollable.block();
377404
let Ok(n) = this.check-write(); // eliding error handling
378405
let len = min(n, num_zeroes);
379406
this.write-zeroes(len); // eliding error handling
380407
num_zeroes -= len;
381408
}
382409
this.flush();
383410
// Wait for completion of `flush`
384-
poll-one(pollable);
411+
pollable.block();
385412
// Check for any errors that arose during `flush`
386413
let _ = this.check-write(); // eliding error handling
387414
</code></pre>
@@ -432,7 +459,7 @@ is ready for reading, before performing the <code>splice</code>.</p>
432459
<ul>
433460
<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>
434461
</ul>
435-
<h2><a name="wasi:cli_stdout_0.2.0_rc_2023_11_10">Import interface wasi:cli/stdout@0.2.0-rc-2023-11-10</a></h2>
462+
<h2><a name="wasi:cli_stdout_0.2.0_rc_2023_12_05">Import interface wasi:cli/stdout@0.2.0-rc-2023-12-05</a></h2>
436463
<hr />
437464
<h3>Types</h3>
438465
<h4><a name="output_stream"><code>type output-stream</code></a></h4>
@@ -445,7 +472,7 @@ is ready for reading, before performing the <code>splice</code>.</p>
445472
<ul>
446473
<li><a name="get_stdout.0"></a> own&lt;<a href="#output_stream"><a href="#output_stream"><code>output-stream</code></a></a>&gt;</li>
447474
</ul>
448-
<h2><a name="wasi:cli_stderr_0.2.0_rc_2023_11_10">Import interface wasi:cli/stderr@0.2.0-rc-2023-11-10</a></h2>
475+
<h2><a name="wasi:cli_stderr_0.2.0_rc_2023_12_05">Import interface wasi:cli/stderr@0.2.0-rc-2023-12-05</a></h2>
449476
<hr />
450477
<h3>Types</h3>
451478
<h4><a name="output_stream"><code>type output-stream</code></a></h4>
@@ -458,7 +485,7 @@ is ready for reading, before performing the <code>splice</code>.</p>
458485
<ul>
459486
<li><a name="get_stderr.0"></a> own&lt;<a href="#output_stream"><a href="#output_stream"><code>output-stream</code></a></a>&gt;</li>
460487
</ul>
461-
<h2><a name="wasi:cli_stdin_0.2.0_rc_2023_11_10">Import interface wasi:cli/stdin@0.2.0-rc-2023-11-10</a></h2>
488+
<h2><a name="wasi:cli_stdin_0.2.0_rc_2023_12_05">Import interface wasi:cli/stdin@0.2.0-rc-2023-12-05</a></h2>
462489
<hr />
463490
<h3>Types</h3>
464491
<h4><a name="input_stream"><code>type input-stream</code></a></h4>
@@ -532,7 +559,7 @@ occured.</p>
532559
<ul>
533560
<li><a name="subscribe_duration.0"></a> own&lt;<a href="#pollable"><a href="#pollable"><code>pollable</code></a></a>&gt;</li>
534561
</ul>
535-
<h2><a name="wasi:http_types_0.2.0_rc_2023_11_10">Import interface wasi:http/types@0.2.0-rc-2023-11-10</a></h2>
562+
<h2><a name="wasi:http_types_0.2.0_rc_2023_12_05">Import interface wasi:http/types@0.2.0-rc-2023-12-05</a></h2>
536563
<p>This interface defines all of the types and methods for implementing
537564
HTTP Requests and Responses, both incoming and outgoing, as well as
538565
their headers, trailers, and bodies.</p>
@@ -678,26 +705,76 @@ permitted because the fields are immutable.
678705
reality, HTTP implementations often have to interpret malformed values,
679706
so they are provided as a list of bytes.
680707
<h4><a name="fields"><code>resource fields</code></a></h4>
708+
<p>This following block defines the <a href="#fields"><code>fields</code></a> resource which corresponds to
709+
HTTP standard Fields. Fields are a common representation used for both
710+
Headers and Trailers.</p>
711+
<p>A <a href="#fields"><code>fields</code></a> may be mutable or immutable. A <a href="#fields"><code>fields</code></a> created using the
712+
constructor, <code>from-list</code>, or <code>clone</code> will be mutable, but a <a href="#fields"><code>fields</code></a>
713+
resource given by other means (including, but not limited to,
714+
<code>incoming-request.headers</code>, <code>outgoing-request.headers</code>) might be be
715+
immutable. In an immutable fields, the <code>set</code>, <code>append</code>, and <code>delete</code>
716+
operations will fail with <code>header-error.immutable</code>.</p>
681717
<h4><a name="headers"><code>type headers</code></a></h4>
682718
<p><a href="#fields"><a href="#fields"><code>fields</code></a></a></p>
683719
<p>Headers is an alias for Fields.
684720
<h4><a name="trailers"><code>type trailers</code></a></h4>
685721
<p><a href="#fields"><a href="#fields"><code>fields</code></a></a></p>
686722
<p>Trailers is an alias for Fields.
687723
<h4><a name="incoming_request"><code>resource incoming-request</code></a></h4>
724+
<p>Represents an incoming HTTP Request.</p>
688725
<h4><a name="outgoing_request"><code>resource outgoing-request</code></a></h4>
726+
<p>Represents an outgoing HTTP Request.</p>
689727
<h4><a name="request_options"><code>resource request-options</code></a></h4>
728+
<p>Parameters for making an HTTP Request. Each of these parameters is
729+
currently an optional timeout applicable to the transport layer of the
730+
HTTP protocol.</p>
731+
<p>These timeouts are separate from any the user may use to bound a
732+
blocking call to <code>wasi:io/poll.poll</code>.</p>
690733
<h4><a name="response_outparam"><code>resource response-outparam</code></a></h4>
734+
<p>Represents the ability to send an HTTP Response.</p>
735+
<p>This resource is used by the <code>wasi:http/incoming-handler</code> interface to
736+
allow a Response to be sent corresponding to the Request provided as the
737+
other argument to <code>incoming-handler.handle</code>.</p>
691738
<h4><a name="status_code"><code>type status-code</code></a></h4>
692739
<p><code>u16</code></p>
693740
<p>This type corresponds to the HTTP standard Status Code.
694741
<h4><a name="incoming_response"><code>resource incoming-response</code></a></h4>
742+
<p>Represents an incoming HTTP Response.</p>
695743
<h4><a name="incoming_body"><code>resource incoming-body</code></a></h4>
744+
<p>Represents an incoming HTTP Request or Response's Body.</p>
745+
<p>A body has both its contents - a stream of bytes - and a (possibly
746+
empty) set of trailers, indicating that the full contents of the
747+
body have been received. This resource represents the contents as
748+
an <a href="#input_stream"><code>input-stream</code></a> and the delivery of trailers as a <a href="#future_trailers"><code>future-trailers</code></a>,
749+
and ensures that the user of this interface may only be consuming either
750+
the body contents or waiting on trailers at any given time.</p>
696751
<h4><a name="future_trailers"><code>resource future-trailers</code></a></h4>
752+
<p>Represents a future which may eventaully return trailers, or an error.</p>
753+
<p>In the case that the incoming HTTP Request or Response did not have any
754+
trailers, this future will resolve to the empty set of trailers once the
755+
complete Request or Response body has been received.</p>
697756
<h4><a name="outgoing_response"><code>resource outgoing-response</code></a></h4>
757+
<p>Represents an outgoing HTTP Response.</p>
698758
<h4><a name="outgoing_body"><code>resource outgoing-body</code></a></h4>
759+
<p>Represents an outgoing HTTP Request or Response's Body.</p>
760+
<p>A body has both its contents - a stream of bytes - and a (possibly
761+
empty) set of trailers, inducating the full contents of the body
762+
have been sent. This resource represents the contents as an
763+
<a href="#output_stream"><code>output-stream</code></a> child resource, and the completion of the body (with
764+
optional trailers) with a static function that consumes the
765+
<a href="#outgoing_body"><code>outgoing-body</code></a> resource, and ensures that the user of this interface
766+
may not write to the body contents after the body has been finished.</p>
767+
<p>If the user code drops this resource, as opposed to calling the static
768+
method <code>finish</code>, the implementation should treat the body as incomplete,
769+
and that an error has occured. The implementation should propogate this
770+
error to the HTTP protocol by whatever means it has available,
771+
including: corrupting the body on the wire, aborting the associated
772+
Request, or sending a late status code for the Response.</p>
699773
<h4><a name="future_incoming_response"><code>resource future-incoming-response</code></a></h4>
700-
<hr />
774+
<p>Represents a future which may eventaully return an incoming HTTP
775+
Response, or an error.</p>
776+
<h2>This resource is returned by the <code>wasi:http/outgoing-handler</code> interface to
777+
provide the HTTP Response corresponding to the sent Request.</h2>
701778
<h3>Functions</h3>
702779
<h4><a name="http_error_code"><code>http-error-code: func</code></a></h4>
703780
<p>Attempts to extract a http-related <a href="#error"><code>error</code></a> from the wasi:io <a href="#error"><code>error</code></a>
@@ -1368,7 +1445,7 @@ but those will be reported by the <a href="#incoming_body"><code>incoming-body</
13681445
<ul>
13691446
<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>
13701447
</ul>
1371-
<h2><a name="wasi:http_outgoing_handler_0.2.0_rc_2023_11_10">Import interface wasi:http/outgoing-handler@0.2.0-rc-2023-11-10</a></h2>
1448+
<h2><a name="wasi:http_outgoing_handler_0.2.0_rc_2023_12_05">Import interface wasi:http/outgoing-handler@0.2.0-rc-2023-12-05</a></h2>
13721449
<p>This interface defines a handler of outgoing HTTP Requests. It should be
13731450
imported by components which wish to make HTTP Requests.</p>
13741451
<hr />
@@ -1446,7 +1523,7 @@ also known as <a href="https://en.wikipedia.org/wiki/Unix_time">Unix Time</a>.</
14461523
<ul>
14471524
<li><a name="resolution.0"></a> <a href="#datetime"><a href="#datetime"><code>datetime</code></a></a></li>
14481525
</ul>
1449-
<h2><a name="wasi:http_incoming_handler_0.2.0_rc_2023_11_10">Export interface wasi:http/incoming-handler@0.2.0-rc-2023-11-10</a></h2>
1526+
<h2><a name="wasi:http_incoming_handler_0.2.0_rc_2023_12_05">Export interface wasi:http/incoming-handler@0.2.0-rc-2023-12-05</a></h2>
14501527
<hr />
14511528
<h3>Types</h3>
14521529
<h4><a name="incoming_request"><code>type incoming-request</code></a></h4>

0 commit comments

Comments
 (0)