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.

  • interface wasi:io/error@0.2.0-rc-2023-11-10
  • interface wasi:io/poll@0.2.0-rc-2023-11-10
  • interface wasi:io/streams@0.2.0-rc-2023-11-10
  • -
  • interface wasi:cli/stdout@0.2.0-rc-2023-11-10
  • -
  • interface wasi:cli/stderr@0.2.0-rc-2023-11-10
  • -
  • interface wasi:cli/stdin@0.2.0-rc-2023-11-10
  • +
  • interface wasi:cli/stdout@0.2.0-rc-2023-12-05
  • +
  • interface wasi:cli/stderr@0.2.0-rc-2023-12-05
  • +
  • interface wasi:cli/stdin@0.2.0-rc-2023-12-05
  • interface wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10
  • -
  • interface wasi:http/types@0.2.0-rc-2023-11-10
  • -
  • interface wasi:http/outgoing-handler@0.2.0-rc-2023-11-10
  • +
  • interface wasi:http/types@0.2.0-rc-2023-12-05
  • +
  • interface wasi:http/outgoing-handler@0.2.0-rc-2023-12-05
  • interface wasi:clocks/wall-clock@0.2.0-rc-2023-11-10
  • Exports:
  • @@ -62,7 +62,21 @@ represented as a u64.


    Types

    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, errors 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>.

    +

    The set of functions which can "downcast" an error into a more +concrete type is open.

    Functions

    [method]error.to-debug-string: func

    Returns a string that is suitable to assist humans in debugging @@ -85,7 +99,7 @@ at once.


    Types

    resource pollable

    -
    +

    pollable represents a single I/O event which may be ready, or not.

    Functions

    [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-streams 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-streams 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.

    Functions

    [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 pollables 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.

    @@ -373,7 +400,7 @@ the following pseudo-code:

    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.

    -

    Import interface wasi:cli/stdout@0.2.0-rc-2023-11-10

    +

    Import interface wasi:cli/stdout@0.2.0-rc-2023-12-05


    Types

    type output-stream

    @@ -445,7 +472,7 @@ is ready for reading, before performing the splice.

    -

    Import interface wasi:cli/stderr@0.2.0-rc-2023-11-10

    +

    Import interface wasi:cli/stderr@0.2.0-rc-2023-12-05


    Types

    type output-stream

    @@ -458,7 +485,7 @@ is ready for reading, before performing the splice.

    -

    Import interface wasi:cli/stdin@0.2.0-rc-2023-11-10

    +

    Import interface wasi:cli/stdin@0.2.0-rc-2023-12-05


    Types

    type input-stream

    @@ -532,7 +559,7 @@ occured.

    -

    Import interface wasi:http/types@0.2.0-rc-2023-11-10

    +

    Import interface wasi:http/types@0.2.0-rc-2023-12-05

    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

    fields

    Headers is an alias for Fields. @@ -685,19 +721,60 @@ so they are provided as a list of bytes.

    fields

    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.

    +

    This resource is returned by the wasi:http/outgoing-handler interface to +provide the HTTP Response corresponding to the sent Request.

    Functions

    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

  • option<result<result<own<incoming-response>, error-code>>>
  • -

    Import interface wasi:http/outgoing-handler@0.2.0-rc-2023-11-10

    +

    Import interface wasi:http/outgoing-handler@0.2.0-rc-2023-12-05

    This interface defines a handler of outgoing HTTP Requests. It should be imported by components which wish to make HTTP Requests.


    @@ -1446,7 +1523,7 @@ also known as Unix Time.
  • datetime
  • -

    Export interface wasi:http/incoming-handler@0.2.0-rc-2023-11-10

    +

    Export interface wasi:http/incoming-handler@0.2.0-rc-2023-12-05


    Types

    type incoming-request

    diff --git a/wit/deps.lock b/wit/deps.lock index 661a351..01efeef 100644 --- a/wit/deps.lock +++ b/wit/deps.lock @@ -1,7 +1,7 @@ [cli] url = "https://github.com/WebAssembly/wasi-cli/archive/main.tar.gz" -sha256 = "fb029d0f9468fcb404a079a58fafd9265ef99c0ee1350835348da7b6e105c597" -sha512 = "8602e881281adc67b1ac5a4eb0888636d6f50d15bd14e36dcc446a51551f3f9bb3e9eabb776d723bb113bf1e26a702c5042de095e66e897c3d3cf689e0b7d4f9" +sha256 = "6894203a2ac50a68f6b91f2174826c2987cc0efc94ad1f8f14f8460e262fc103" +sha512 = "349776db1b1455e176ca61a1a8ec653f77b888d291e948feded3b6b46350c65973e9e75cc0bf8649256654001af2408eacc585c31454008c86ff53b301da5c32" [clocks] url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz" @@ -15,8 +15,8 @@ sha512 = "2c242489801a75466986fe014d730fb3aa7b5c6e56a230c8735e6672711b58bcbe92ba [io] url = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz" -sha256 = "f2e6127b235c37c06be675a904d6acf08db953ea688d78c42892c6ad3bd194e4" -sha512 = "32feefbc115c34bf6968cb6e9dc15e755698ee90648e5a5d84448917c36a318bd61b401195eb64330e2475e1d098bfb8dee1440d594a68e0797748762bd84ae5" +sha256 = "b622db2755978a49d18d35d84d75f66b2b1ed23d7bf413e5c9e152e190cc7d4b" +sha512 = "d19c9004e75bf3ebe3e34cff498c3d7fee04cd57a7fba7ed12a0c5ad842ba5715c009de77a152c57da0500f6ca0986b6791b6f022829bdd5a024f7bc114c2ff6" [random] url = "https://github.com/WebAssembly/wasi-random/archive/main.tar.gz" diff --git a/wit/deps/cli/command.wit b/wit/deps/cli/command.wit index 74811d3..cc82ae5 100644 --- a/wit/deps/cli/command.wit +++ b/wit/deps/cli/command.wit @@ -1,7 +1,7 @@ -package wasi:cli@0.2.0-rc-2023-11-10; +package wasi:cli@0.2.0-rc-2023-12-05; world command { - include reactor; + include imports; export run; } diff --git a/wit/deps/cli/imports.wit b/wit/deps/cli/imports.wit new file mode 100644 index 0000000..9965ea3 --- /dev/null +++ b/wit/deps/cli/imports.wit @@ -0,0 +1,20 @@ +package wasi:cli@0.2.0-rc-2023-12-05; + +world imports { + include wasi:clocks/imports@0.2.0-rc-2023-11-10; + include wasi:filesystem/imports@0.2.0-rc-2023-11-10; + include wasi:sockets/imports@0.2.0-rc-2023-11-10; + include wasi:random/imports@0.2.0-rc-2023-11-10; + include wasi:io/imports@0.2.0-rc-2023-11-10; + + import environment; + import exit; + import stdin; + import stdout; + import stderr; + import terminal-input; + import terminal-output; + import terminal-stdin; + import terminal-stdout; + import terminal-stderr; +} diff --git a/wit/deps/cli/reactor.wit b/wit/deps/cli/reactor.wit deleted file mode 100644 index eafa2fd..0000000 --- a/wit/deps/cli/reactor.wit +++ /dev/null @@ -1,31 +0,0 @@ -package wasi:cli@0.2.0-rc-2023-11-10; - -world reactor { - import wasi:clocks/wall-clock@0.2.0-rc-2023-11-10; - import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10; - import wasi:filesystem/types@0.2.0-rc-2023-11-10; - import wasi:filesystem/preopens@0.2.0-rc-2023-11-10; - import wasi:sockets/instance-network@0.2.0-rc-2023-11-10; - import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10; - import wasi:sockets/network@0.2.0-rc-2023-11-10; - import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-10; - import wasi:sockets/tcp@0.2.0-rc-2023-11-10; - import wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-10; - import wasi:sockets/udp@0.2.0-rc-2023-11-10; - import wasi:random/random@0.2.0-rc-2023-11-10; - import wasi:random/insecure@0.2.0-rc-2023-11-10; - import wasi:random/insecure-seed@0.2.0-rc-2023-11-10; - import wasi:io/poll@0.2.0-rc-2023-11-10; - import wasi:io/streams@0.2.0-rc-2023-11-10; - - import environment; - import exit; - import stdin; - import stdout; - import stderr; - import terminal-input; - import terminal-output; - import terminal-stdin; - import terminal-stdout; - import terminal-stderr; -} diff --git a/wit/deps/io/poll.wit b/wit/deps/io/poll.wit index bddde3c..81b1cab 100644 --- a/wit/deps/io/poll.wit +++ b/wit/deps/io/poll.wit @@ -3,7 +3,7 @@ package wasi:io@0.2.0-rc-2023-11-10; /// A poll API intended to let users wait for I/O events on multiple handles /// at once. interface poll { - /// `pollable` epresents a single I/O event which may be ready, or not. + /// `pollable` represents a single I/O event which may be ready, or not. resource pollable { /// Return the readiness of a pollable. This function never blocks. diff --git a/wit/deps/io/streams.wit b/wit/deps/io/streams.wit index e7e1b68..f6f7fe0 100644 --- a/wit/deps/io/streams.wit +++ b/wit/deps/io/streams.wit @@ -131,7 +131,7 @@ interface streams { /// 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); @@ -140,7 +140,7 @@ interface streams { /// } /// 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 /// ``` @@ -178,7 +178,7 @@ interface streams { /// 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. @@ -199,7 +199,7 @@ interface streams { /// 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 @@ -207,7 +207,7 @@ interface streams { /// } /// 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 /// ``` diff --git a/wit/proxy.wit b/wit/proxy.wit index ee4ff33..0f466c9 100644 --- a/wit/proxy.wit +++ b/wit/proxy.wit @@ -1,4 +1,4 @@ -package wasi:http@0.2.0-rc-2023-11-10; +package wasi:http@0.2.0-rc-2023-12-05; /// The `wasi:http/proxy` world captures a widely-implementable intersection of /// hosts that includes HTTP forward and reverse proxies. Components targeting @@ -11,14 +11,14 @@ world proxy { /// Proxies have standard output and error streams which are expected to /// terminate in a developer-facing console provided by the host. - import wasi:cli/stdout@0.2.0-rc-2023-11-10; - import wasi:cli/stderr@0.2.0-rc-2023-11-10; + import wasi:cli/stdout@0.2.0-rc-2023-12-05; + import wasi:cli/stderr@0.2.0-rc-2023-12-05; /// TODO: this is a temporary workaround until component tooling is able to /// gracefully handle the absence of stdin. Hosts must return an eof stream /// for this import, which is what wasi-libc + tooling will do automatically /// when this import is properly removed. - import wasi:cli/stdin@0.2.0-rc-2023-11-10; + import wasi:cli/stdin@0.2.0-rc-2023-12-05; /// This is the default handler to use when user code simply wants to make an /// HTTP request (e.g., via `fetch()`).