diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb189df..ed406c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,3 +17,5 @@ jobs: chmod +x ./wit-deps ./wit-deps lock --check - uses: WebAssembly/wit-abi-up-to-date@v16 + with: + wit-bindgen: '0.15.0' diff --git a/proxy.md b/proxy.md index b05200c..2aa0c46 100644 --- a/proxy.md +++ b/proxy.md @@ -10,18 +10,18 @@ outgoing HTTP requests.
wasi:io/error@0.2.0-rc-2023-11-10
wasi:io/poll@0.2.0-rc-2023-11-10
wasi:io/streams@0.2.0-rc-2023-11-10
wasi:cli/stdout@0.2.0-rc-2023-11-10
wasi:cli/stderr@0.2.0-rc-2023-11-10
wasi:cli/stdin@0.2.0-rc-2023-11-10
wasi:cli/stdout@0.2.0-rc-2023-12-05
wasi:cli/stderr@0.2.0-rc-2023-12-05
wasi:cli/stdin@0.2.0-rc-2023-12-05
wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10
wasi:http/types@0.2.0-rc-2023-11-10
wasi:http/outgoing-handler@0.2.0-rc-2023-11-10
wasi:http/types@0.2.0-rc-2023-12-05
wasi:http/outgoing-handler@0.2.0-rc-2023-12-05
wasi:clocks/wall-clock@0.2.0-rc-2023-11-10
wasi:http/incoming-handler@0.2.0-rc-2023-11-10
wasi:http/incoming-handler@0.2.0-rc-2023-12-05
u64
.
resource error
A resource which represents some error information.
+The only method provided by this resource is to-debug-string
,
+which provides some human-readable information about the error.
In the wasi:io
package, this resource is returned through the
+wasi:io/streams/stream-error
type.
To provide more specific error information, other interfaces may
+provide functions to further "downcast" this error into more specific
+error information. For example, error
s returned in streams derived
+from filesystem types to be described using the filesystem's own
+error-code type, using the function
+wasi:filesystem/types/filesystem-error-code
, which takes a parameter
+borrow<error>
and returns
+option<wasi:filesystem/types/error-code>
.
error
into a more
+concrete type is open.[method]error.to-debug-string: func
Returns a string that is suitable to assist humans in debugging @@ -85,7 +99,7 @@ at once.
resource pollable
pollable
represents a single I/O event which may be ready, or not.[method]pollable.ready: func
Return the readiness of a pollable. This function never blocks.
@@ -159,8 +173,21 @@ future operations.resource input-stream
An input bytestream.
+input-stream
s are non-blocking to the extent practical on underlying
+platforms. I/O operations always return promptly; if fewer bytes are
+promptly available than requested, they return the number of bytes promptly
+available, which could even be zero. To wait for data to be available,
+use the subscribe
function to obtain a pollable
which can be polled
+for using wasi:io/poll
.
resource output-stream
An output bytestream.
+output-stream
s are non-blocking to the extent practical on
+underlying platforms. Except where specified otherwise, I/O operations also
+always return promptly, after the number of bytes that can be written
+promptly, which could even be zero. To wait for the stream to be ready to
+accept data, the subscribe
function to obtain a pollable
which can be
+polled for using wasi:io/poll
.[method]input-stream.read: func
Perform a non-blocking read from the stream.
@@ -281,7 +308,7 @@ following pseudo-code:let pollable = this.subscribe();
while !contents.is_empty() {
// Wait for the stream to become writable
- poll-one(pollable);
+ pollable.block();
let Ok(n) = this.check-write(); // eliding error handling
let len = min(n, contents.len());
let (chunk, rest) = contents.split_at(len);
@@ -290,7 +317,7 @@ while !contents.is_empty() {
}
this.flush();
// Wait for completion of `flush`
-poll-one(pollable);
+pollable.block();
// Check for any errors that arose during `flush`
let _ = this.check-write(); // eliding error handling
@@ -350,7 +377,7 @@ all derived pollable
s created with this fun
[method]output-stream.write-zeroes: func
Write zeroes to a stream.
-this should be used precisely like write
with the exact same
+
This should be used precisely like write
with the exact same
preconditions (must use check-write first), but instead of
passing a list of bytes, you simply pass the number of zero-bytes
that should be written.
let pollable = this.subscribe();
while num_zeroes != 0 {
// Wait for the stream to become writable
- poll-one(pollable);
+ pollable.block();
let Ok(n) = this.check-write(); // eliding error handling
let len = min(n, num_zeroes);
this.write-zeroes(len); // eliding error handling
@@ -381,7 +408,7 @@ while num_zeroes != 0 {
}
this.flush();
// Wait for completion of `flush`
-poll-one(pollable);
+pollable.block();
// Check for any errors that arose during `flush`
let _ = this.check-write(); // eliding error handling
@@ -432,7 +459,7 @@ is ready for reading, before performing the splice
.
u64
, stream-error
>type output-stream
splice
.
output-stream
>type output-stream
splice
.
output-stream
>type input-stream
pollable
>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.
@@ -678,6 +705,15 @@ permitted because the fields are immutable. reality, HTTP implementations often have to interpret malformed values, so they are provided as a list of bytes.resource fields
This following block defines the fields
resource which corresponds to
+HTTP standard Fields. Fields are a common representation used for both
+Headers and Trailers.
A fields
may be mutable or immutable. A fields
created using the
+constructor, from-list
, or clone
will be mutable, but a fields
+resource given by other means (including, but not limited to,
+incoming-request.headers
, outgoing-request.headers
) might be be
+immutable. In an immutable fields, the set
, append
, and delete
+operations will fail with header-error.immutable
.
type headers
Headers is an alias for Fields. @@ -685,19 +721,60 @@ so they are provided as a list of bytes.
Trailers is an alias for Fields.
resource incoming-request
Represents an incoming HTTP Request.
resource outgoing-request
Represents an outgoing HTTP Request.
resource request-options
Parameters for making an HTTP Request. Each of these parameters is +currently an optional timeout applicable to the transport layer of the +HTTP protocol.
+These timeouts are separate from any the user may use to bound a
+blocking call to wasi:io/poll.poll
.
resource response-outparam
Represents the ability to send an HTTP Response.
+This resource is used by the wasi:http/incoming-handler
interface to
+allow a Response to be sent corresponding to the Request provided as the
+other argument to incoming-handler.handle
.
type status-code
u16
This type corresponds to the HTTP standard Status Code.
resource incoming-response
Represents an incoming HTTP Response.
resource incoming-body
Represents an incoming HTTP Request or Response's Body.
+A body has both its contents - a stream of bytes - and a (possibly
+empty) set of trailers, indicating that the full contents of the
+body have been received. This resource represents the contents as
+an input-stream
and the delivery of trailers as a future-trailers
,
+and ensures that the user of this interface may only be consuming either
+the body contents or waiting on trailers at any given time.
resource future-trailers
Represents a future which may eventaully return trailers, or an error.
+In the case that the incoming HTTP Request or Response did not have any +trailers, this future will resolve to the empty set of trailers once the +complete Request or Response body has been received.
resource outgoing-response
Represents an outgoing HTTP Response.
resource outgoing-body
Represents an outgoing HTTP Request or Response's Body.
+A body has both its contents - a stream of bytes - and a (possibly
+empty) set of trailers, inducating the full contents of the body
+have been sent. This resource represents the contents as an
+output-stream
child resource, and the completion of the body (with
+optional trailers) with a static function that consumes the
+outgoing-body
resource, and ensures that the user of this interface
+may not write to the body contents after the body has been finished.
If the user code drops this resource, as opposed to calling the static
+method finish
, the implementation should treat the body as incomplete,
+and that an error has occured. The implementation should propogate this
+error to the HTTP protocol by whatever means it has available,
+including: corrupting the body on the wire, aborting the associated
+Request, or sending a late status code for the Response.
resource future-incoming-response
Represents a future which may eventaully return an incoming HTTP +Response, or an error.
+wasi:http/outgoing-handler
interface to
+provide the HTTP Response corresponding to the sent Request.http-error-code: func
Attempts to extract a http-related error
from the wasi:io error
@@ -1368,7 +1445,7 @@ but those will be reported by the incoming-body
>,
incoming-response
error-code
>>>
-
This interface defines a handler of outgoing HTTP Requests. It should be imported by components which wish to make HTTP Requests.
type incoming-request