@@ -10,18 +10,18 @@ outgoing HTTP requests.</p>
10
10
<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 >
11
11
<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 >
12
12
<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 >
16
16
<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 >
19
19
<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 >
20
20
</ul >
21
21
</li >
22
22
<li >Exports:
23
23
<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 >
25
25
</ul >
26
26
</li >
27
27
</ul >
@@ -62,7 +62,21 @@ represented as a <code>u64</code>.</p>
62
62
<hr />
63
63
<h3 >Types</h3 >
64
64
<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 " ; downcast" ; 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< ; error> ; </code > and returns
77
+ <code >option< ; wasi: filesystem /types/error-code> ; </code >.</p >
78
+ <h2 >The set of functions which can " ; downcast" ; an <a href =" #error " ><code >error</code ></a > into a more
79
+ concrete type is open.</h2 >
66
80
<h3 >Functions</h3 >
67
81
<h4 ><a name =" method_error.to_debug_string " ><code >[method]error.to-debug-string: func</code ></a ></h4 >
68
82
<p >Returns a string that is suitable to assist humans in debugging
@@ -85,7 +99,7 @@ at once.</p>
85
99
<hr />
86
100
<h3 >Types</h3 >
87
101
<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 >
89
103
<h3 >Functions</h3 >
90
104
<h4 ><a name =" method_pollable.ready " ><code >[method]pollable.ready: func</code ></a ></h4 >
91
105
<p >Return the readiness of a pollable. This function never blocks.</p >
@@ -159,8 +173,21 @@ future operations.
159
173
</li >
160
174
</ul >
161
175
<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 >
162
183
<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 >
164
191
<h3 >Functions</h3 >
165
192
<h4 ><a name =" method_input_stream.read " ><code >[method]input-stream.read: func</code ></a ></h4 >
166
193
<p >Perform a non-blocking read from the stream.</p >
@@ -281,7 +308,7 @@ following pseudo-code:</p>
281
308
<pre ><code class =" language-text " >let pollable = this.subscribe();
282
309
while !contents.is_empty() {
283
310
// Wait for the stream to become writable
284
- poll-one( pollable);
311
+ pollable.block( );
285
312
let Ok(n) = this.check-write(); // eliding error handling
286
313
let len = min(n, contents.len());
287
314
let (chunk, rest) = contents.split_at(len);
@@ -290,7 +317,7 @@ while !contents.is_empty() {
290
317
}
291
318
this.flush();
292
319
// Wait for completion of `flush`
293
- poll-one( pollable);
320
+ pollable.block( );
294
321
// Check for any errors that arose during `flush`
295
322
let _ = this.check-write(); // eliding error handling
296
323
</code ></pre >
@@ -350,7 +377,7 @@ all derived <a href="#pollable"><code>pollable</code></a>s created with this fun
350
377
</ul >
351
378
<h4 ><a name =" method_output_stream.write_zeroes " ><code >[method]output-stream.write-zeroes: func</code ></a ></h4 >
352
379
<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
354
381
preconditions (must use check-write first), but instead of
355
382
passing a list of bytes, you simply pass the number of zero-bytes
356
383
that should be written.</p >
@@ -373,15 +400,15 @@ the following pseudo-code:</p>
373
400
<pre ><code class =" language-text " >let pollable = this.subscribe();
374
401
while num_zeroes != 0 {
375
402
// Wait for the stream to become writable
376
- poll-one( pollable);
403
+ pollable.block( );
377
404
let Ok(n) = this.check-write(); // eliding error handling
378
405
let len = min(n, num_zeroes);
379
406
this.write-zeroes(len); // eliding error handling
380
407
num_zeroes -= len;
381
408
}
382
409
this.flush();
383
410
// Wait for completion of `flush`
384
- poll-one( pollable);
411
+ pollable.block( );
385
412
// Check for any errors that arose during `flush`
386
413
let _ = this.check-write(); // eliding error handling
387
414
</code ></pre >
@@ -432,7 +459,7 @@ is ready for reading, before performing the <code>splice</code>.</p>
432
459
<ul >
433
460
<li ><a name =" method_output_stream.blocking_splice.0 " ></a > result< ; <code >u64</code >, <a href =" #stream_error " ><a href =" #stream_error " ><code >stream-error</code ></a ></a >> ; </li >
434
461
</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 >
436
463
<hr />
437
464
<h3 >Types</h3 >
438
465
<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>
445
472
<ul >
446
473
<li ><a name =" get_stdout.0 " ></a > own< ; <a href =" #output_stream " ><a href =" #output_stream " ><code >output-stream</code ></a ></a >> ; </li >
447
474
</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 >
449
476
<hr />
450
477
<h3 >Types</h3 >
451
478
<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>
458
485
<ul >
459
486
<li ><a name =" get_stderr.0 " ></a > own< ; <a href =" #output_stream " ><a href =" #output_stream " ><code >output-stream</code ></a ></a >> ; </li >
460
487
</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 >
462
489
<hr />
463
490
<h3 >Types</h3 >
464
491
<h4 ><a name =" input_stream " ><code >type input-stream</code ></a ></h4 >
@@ -532,7 +559,7 @@ occured.</p>
532
559
<ul >
533
560
<li ><a name =" subscribe_duration.0 " ></a > own< ; <a href =" #pollable " ><a href =" #pollable " ><code >pollable</code ></a ></a >> ; </li >
534
561
</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 >
536
563
<p >This interface defines all of the types and methods for implementing
537
564
HTTP Requests and Responses, both incoming and outgoing, as well as
538
565
their headers, trailers, and bodies.</p >
@@ -678,26 +705,76 @@ permitted because the fields are immutable.
678
705
reality, HTTP implementations often have to interpret malformed values,
679
706
so they are provided as a list of bytes.
680
707
<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 >
681
717
<h4 ><a name =" headers " ><code >type headers</code ></a ></h4 >
682
718
<p ><a href =" #fields " ><a href =" #fields " ><code >fields</code ></a ></a ></p >
683
719
<p >Headers is an alias for Fields.
684
720
<h4 ><a name =" trailers " ><code >type trailers</code ></a ></h4 >
685
721
<p ><a href =" #fields " ><a href =" #fields " ><code >fields</code ></a ></a ></p >
686
722
<p >Trailers is an alias for Fields.
687
723
<h4 ><a name =" incoming_request " ><code >resource incoming-request</code ></a ></h4 >
724
+ <p >Represents an incoming HTTP Request.</p >
688
725
<h4 ><a name =" outgoing_request " ><code >resource outgoing-request</code ></a ></h4 >
726
+ <p >Represents an outgoing HTTP Request.</p >
689
727
<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 >
690
733
<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 >
691
738
<h4 ><a name =" status_code " ><code >type status-code</code ></a ></h4 >
692
739
<p ><code >u16</code ></p >
693
740
<p >This type corresponds to the HTTP standard Status Code.
694
741
<h4 ><a name =" incoming_response " ><code >resource incoming-response</code ></a ></h4 >
742
+ <p >Represents an incoming HTTP Response.</p >
695
743
<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 >
696
751
<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 >
697
756
<h4 ><a name =" outgoing_response " ><code >resource outgoing-response</code ></a ></h4 >
757
+ <p >Represents an outgoing HTTP Response.</p >
698
758
<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 >
699
773
<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 >
701
778
<h3 >Functions</h3 >
702
779
<h4 ><a name =" http_error_code " ><code >http-error-code: func</code ></a ></h4 >
703
780
<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</
1368
1445
<ul >
1369
1446
<li ><a name =" method_future_incoming_response.get.0 " ></a > option< ; result< ; result< ; own< ; <a href =" #incoming_response " ><a href =" #incoming_response " ><code >incoming-response</code ></a ></a >> ; , <a href =" #error_code " ><a href =" #error_code " ><code >error-code</code ></a ></a >> ;> ;> ; </li >
1370
1447
</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 >
1372
1449
<p >This interface defines a handler of outgoing HTTP Requests. It should be
1373
1450
imported by components which wish to make HTTP Requests.</p >
1374
1451
<hr />
@@ -1446,7 +1523,7 @@ also known as <a href="https://en.wikipedia.org/wiki/Unix_time">Unix Time</a>.</
1446
1523
<ul >
1447
1524
<li ><a name =" resolution.0 " ></a > <a href =" #datetime " ><a href =" #datetime " ><code >datetime</code ></a ></a ></li >
1448
1525
</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 >
1450
1527
<hr />
1451
1528
<h3 >Types</h3 >
1452
1529
<h4 ><a name =" incoming_request " ><code >type incoming-request</code ></a ></h4 >
0 commit comments