Skip to content
Merged
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: 16 additions & 16 deletions ci/vendor-wit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ make_vendor() {
cache_dir=$(mktemp -d)

make_vendor "wasi-io" "
io@v0.2.3
io@v0.2.6
"

make_vendor "wasi/src/p2" "
cli@v0.2.3
clocks@v0.2.3
filesystem@v0.2.3
io@v0.2.3
random@v0.2.3
sockets@v0.2.3
cli@v0.2.6
clocks@v0.2.6
filesystem@v0.2.6
io@v0.2.6
random@v0.2.6
sockets@v0.2.6
"

make_vendor "wasi-http" "
cli@v0.2.3
clocks@v0.2.3
filesystem@v0.2.3
io@v0.2.3
random@v0.2.3
sockets@v0.2.3
http@v0.2.3
cli@v0.2.6
clocks@v0.2.6
filesystem@v0.2.6
io@v0.2.6
random@v0.2.6
sockets@v0.2.6
http@v0.2.6
"

make_vendor "wasi-tls" "
io@v0.2.3
tls@v0.2.0-draft+d6fbdc7
io@v0.2.6
tls@v0.2.0-draft+505fc98
"

make_vendor "wasi-config" "config@f4d699b"
Expand Down
26 changes: 13 additions & 13 deletions crates/test-programs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ wit_bindgen::generate!({
package wasmtime:test;

world test {
include wasi:cli/imports@0.2.3;
include wasi:http/imports@0.2.3;
include wasi:cli/imports@0.2.6;
include wasi:http/imports@0.2.6;
include wasi:config/imports@0.2.0-draft;
include wasi:keyvalue/imports@0.2.0-draft;
include wasi:tls/imports@0.2.0-draft;
Expand All @@ -34,17 +34,17 @@ pub mod proxy {
default_bindings_module: "test_programs::proxy",
pub_export_macro: true,
with: {
"wasi:http/types@0.2.3": crate::wasi::http::types,
"wasi:http/outgoing-handler@0.2.3": crate::wasi::http::outgoing_handler,
"wasi:random/random@0.2.3": crate::wasi::random::random,
"wasi:io/error@0.2.3": crate::wasi::io::error,
"wasi:io/poll@0.2.3": crate::wasi::io::poll,
"wasi:io/streams@0.2.3": crate::wasi::io::streams,
"wasi:cli/stdout@0.2.3": crate::wasi::cli::stdout,
"wasi:cli/stderr@0.2.3": crate::wasi::cli::stderr,
"wasi:cli/stdin@0.2.3": crate::wasi::cli::stdin,
"wasi:clocks/monotonic-clock@0.2.3": crate::wasi::clocks::monotonic_clock,
"wasi:clocks/wall-clock@0.2.3": crate::wasi::clocks::wall_clock,
"wasi:http/types@0.2.6": crate::wasi::http::types,
"wasi:http/outgoing-handler@0.2.6": crate::wasi::http::outgoing_handler,
"wasi:random/random@0.2.6": crate::wasi::random::random,
"wasi:io/error@0.2.6": crate::wasi::io::error,
"wasi:io/poll@0.2.6": crate::wasi::io::poll,
"wasi:io/streams@0.2.6": crate::wasi::io::streams,
"wasi:cli/stdout@0.2.6": crate::wasi::cli::stdout,
"wasi:cli/stderr@0.2.6": crate::wasi::cli::stderr,
"wasi:cli/stdin@0.2.6": crate::wasi::cli::stdin,
"wasi:clocks/monotonic-clock@0.2.6": crate::wasi::clocks::monotonic_clock,
"wasi:clocks/wall-clock@0.2.6": crate::wasi::clocks::wall_clock,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub use self::generated::wasi::*;
pub use self::generated::exports;

/// Bindings to the `wasi:http/proxy` world.
pub use self::generated::{Proxy, ProxyIndices, ProxyPre};
pub use self::generated::{LinkOptions, Proxy, ProxyIndices, ProxyPre};

/// Sync implementation of the `wasi:http/proxy` world.
pub mod sync {
Expand Down
8 changes: 6 additions & 2 deletions crates/wasi-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,13 @@ pub fn add_only_http_to_linker_async<T>(
where
T: WasiHttpView + 'static,
{
let options = crate::bindings::LinkOptions::default(); // FIXME: Thread through to the CLI options.
Comment thread
rvolosatovs marked this conversation as resolved.
crate::bindings::http::outgoing_handler::add_to_linker::<_, WasiHttp<T>>(l, |x| {
WasiHttpImpl(IoImpl(x))
})?;
crate::bindings::http::types::add_to_linker::<_, WasiHttp<T>>(l, |x| WasiHttpImpl(IoImpl(x)))?;
crate::bindings::http::types::add_to_linker::<_, WasiHttp<T>>(l, &options.into(), |x| {
WasiHttpImpl(IoImpl(x))
})?;

Ok(())
}
Expand Down Expand Up @@ -374,10 +377,11 @@ pub fn add_only_http_to_linker_sync<T>(l: &mut Linker<T>) -> anyhow::Result<()>
where
T: WasiHttpView + 'static,
{
let options = crate::bindings::LinkOptions::default(); // FIXME: Thread through to the CLI options.
crate::bindings::sync::http::outgoing_handler::add_to_linker::<_, WasiHttp<T>>(l, |x| {
WasiHttpImpl(IoImpl(x))
})?;
crate::bindings::sync::http::types::add_to_linker::<_, WasiHttp<T>>(l, |x| {
crate::bindings::sync::http::types::add_to_linker::<_, WasiHttp<T>>(l, &options.into(), |x| {
WasiHttpImpl(IoImpl(x))
})?;

Expand Down
13 changes: 11 additions & 2 deletions crates/wasi-http/src/types_impl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Implementation for the `wasi:http/types` interface.

use crate::{
WasiHttpImpl, WasiHttpView,
HttpError, HttpResult, WasiHttpImpl, WasiHttpView,
bindings::http::types::{self, Headers, Method, Scheme, StatusCode, Trailers},
body::{HostFutureTrailers, HostIncomingBody, HostOutgoingBody, StreamContext},
types::{
Expand All @@ -10,7 +10,7 @@ use crate::{
is_forbidden_header, remove_forbidden_headers,
},
};
use anyhow::Context;
use anyhow::{Context, anyhow};
use std::any::Any;
use std::str::FromStr;
use wasmtime::component::{Resource, ResourceTable, ResourceTableError};
Expand Down Expand Up @@ -580,6 +580,15 @@ where
let _ = resp.result.send(val);
Ok(())
}

fn send_informational(
&mut self,
_id: Resource<HostResponseOutparam>,
_status: u16,
_headers: Resource<Headers>,
) -> HttpResult<()> {
Err(HttpError::trap(anyhow!("not implemented")))
}
}

impl<T> crate::bindings::http::types::HostIncomingResponse for WasiHttpImpl<T>
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/cli/command.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:cli@0.2.3;
package wasi:cli@0.2.6;

@since(version = 0.2.0)
world command {
Expand Down
12 changes: 6 additions & 6 deletions crates/wasi-http/wit/deps/cli/imports.wit
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package wasi:cli@0.2.3;
package wasi:cli@0.2.6;

@since(version = 0.2.0)
world imports {
@since(version = 0.2.0)
include wasi:clocks/imports@0.2.3;
include wasi:clocks/imports@0.2.6;
@since(version = 0.2.0)
include wasi:filesystem/imports@0.2.3;
include wasi:filesystem/imports@0.2.6;
@since(version = 0.2.0)
include wasi:sockets/imports@0.2.3;
include wasi:sockets/imports@0.2.6;
@since(version = 0.2.0)
include wasi:random/imports@0.2.3;
include wasi:random/imports@0.2.6;
@since(version = 0.2.0)
include wasi:io/imports@0.2.3;
include wasi:io/imports@0.2.6;

@since(version = 0.2.0)
import environment;
Expand Down
6 changes: 3 additions & 3 deletions crates/wasi-http/wit/deps/cli/stdio.wit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@since(version = 0.2.0)
interface stdin {
@since(version = 0.2.0)
use wasi:io/streams@0.2.3.{input-stream};
use wasi:io/streams@0.2.6.{input-stream};

@since(version = 0.2.0)
get-stdin: func() -> input-stream;
Expand All @@ -10,7 +10,7 @@ interface stdin {
@since(version = 0.2.0)
interface stdout {
@since(version = 0.2.0)
use wasi:io/streams@0.2.3.{output-stream};
use wasi:io/streams@0.2.6.{output-stream};

@since(version = 0.2.0)
get-stdout: func() -> output-stream;
Expand All @@ -19,7 +19,7 @@ interface stdout {
@since(version = 0.2.0)
interface stderr {
@since(version = 0.2.0)
use wasi:io/streams@0.2.3.{output-stream};
use wasi:io/streams@0.2.6.{output-stream};

@since(version = 0.2.0)
get-stderr: func() -> output-stream;
Expand Down
4 changes: 2 additions & 2 deletions crates/wasi-http/wit/deps/clocks/monotonic-clock.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:clocks@0.2.3;
package wasi:clocks@0.2.6;
/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
/// time.
///
Expand All @@ -10,7 +10,7 @@ package wasi:clocks@0.2.3;
@since(version = 0.2.0)
interface monotonic-clock {
@since(version = 0.2.0)
use wasi:io/poll@0.2.3.{pollable};
use wasi:io/poll@0.2.6.{pollable};

/// An instant in time, in nanoseconds. An instant is relative to an
/// unspecified initial value, and can only be compared to instances from
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/clocks/timezone.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:clocks@0.2.3;
package wasi:clocks@0.2.6;

@unstable(feature = clocks-timezone)
interface timezone {
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/clocks/wall-clock.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:clocks@0.2.3;
package wasi:clocks@0.2.6;
/// WASI Wall Clock is a clock API intended to let users query the current
/// time. The name "wall" makes an analogy to a "clock on the wall", which
/// is not necessarily monotonic as it may be reset.
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/clocks/world.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:clocks@0.2.3;
package wasi:clocks@0.2.6;

@since(version = 0.2.0)
world imports {
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/filesystem/preopens.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:filesystem@0.2.3;
package wasi:filesystem@0.2.6;

@since(version = 0.2.0)
interface preopens {
Expand Down
10 changes: 7 additions & 3 deletions crates/wasi-http/wit/deps/filesystem/types.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:filesystem@0.2.3;
package wasi:filesystem@0.2.6;
/// WASI filesystem is a filesystem API primarily intended to let users run WASI
/// programs that access their files on their existing filesystems, without
/// significant overhead.
Expand Down Expand Up @@ -26,9 +26,9 @@ package wasi:filesystem@0.2.3;
@since(version = 0.2.0)
interface types {
@since(version = 0.2.0)
use wasi:io/streams@0.2.3.{input-stream, output-stream, error};
use wasi:io/streams@0.2.6.{input-stream, output-stream, error};
@since(version = 0.2.0)
use wasi:clocks/wall-clock@0.2.3.{datetime};
use wasi:clocks/wall-clock@0.2.6.{datetime};

/// File size or length of a region within a file.
@since(version = 0.2.0)
Expand Down Expand Up @@ -508,6 +508,10 @@ interface types {

/// Create a hard link.
///
/// Fails with `error-code::no-entry` if the old path does not exist,
/// with `error-code::exist` if the new path already exists, and
/// `error-code::not-permitted` if the old path is not a file.
///
/// Note: This is similar to `linkat` in POSIX.
@since(version = 0.2.0)
link-at: func(
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/filesystem/world.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:filesystem@0.2.3;
package wasi:filesystem@0.2.6;

@since(version = 0.2.0)
world imports {
Expand Down
14 changes: 7 additions & 7 deletions crates/wasi-http/wit/deps/http/proxy.wit
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package wasi:http@0.2.3;
package wasi:http@0.2.6;

/// The `wasi:http/imports` world imports all the APIs for HTTP proxies.
/// It is intended to be `include`d in other worlds.
@since(version = 0.2.0)
world imports {
/// HTTP proxies have access to time and randomness.
@since(version = 0.2.0)
import wasi:clocks/monotonic-clock@0.2.3;
import wasi:clocks/monotonic-clock@0.2.6;
@since(version = 0.2.0)
import wasi:clocks/wall-clock@0.2.3;
import wasi:clocks/wall-clock@0.2.6;
@since(version = 0.2.0)
import wasi:random/random@0.2.3;
import wasi:random/random@0.2.6;

/// Proxies have standard output and error streams which are expected to
/// terminate in a developer-facing console provided by the host.
@since(version = 0.2.0)
import wasi:cli/stdout@0.2.3;
import wasi:cli/stdout@0.2.6;
@since(version = 0.2.0)
import wasi:cli/stderr@0.2.3;
import wasi:cli/stderr@0.2.6;

/// 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.
@since(version = 0.2.0)
import wasi:cli/stdin@0.2.3;
import wasi:cli/stdin@0.2.6;

/// This is the default handler to use when user code simply wants to make an
/// HTTP request (e.g., via `fetch()`).
Expand Down
25 changes: 20 additions & 5 deletions crates/wasi-http/wit/deps/http/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
@since(version = 0.2.0)
interface types {
@since(version = 0.2.0)
use wasi:clocks/monotonic-clock@0.2.3.{duration};
use wasi:clocks/monotonic-clock@0.2.6.{duration};
@since(version = 0.2.0)
use wasi:io/streams@0.2.3.{input-stream, output-stream};
use wasi:io/streams@0.2.6.{input-stream, output-stream};
@since(version = 0.2.0)
use wasi:io/error@0.2.3.{error as io-error};
use wasi:io/error@0.2.6.{error as io-error};
@since(version = 0.2.0)
use wasi:io/poll@0.2.3.{pollable};
use wasi:io/poll@0.2.6.{pollable};

/// This type corresponds to HTTP standard Methods.
@since(version = 0.2.0)
Expand Down Expand Up @@ -170,7 +170,7 @@ interface types {
/// 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
/// `incoming-request.headers`, `outgoing-request.headers`) might be
/// immutable. In an immutable fields, the `set`, `append`, and `delete`
/// operations will fail with `header-error.immutable`.
@since(version = 0.2.0)
Expand Down Expand Up @@ -435,6 +435,21 @@ interface types {
/// other argument to `incoming-handler.handle`.
@since(version = 0.2.0)
resource response-outparam {
/// Send an HTTP 1xx response.
///
/// Unlike `response-outparam.set`, this does not consume the
/// `response-outparam`, allowing the guest to send an arbitrary number of
/// informational responses before sending the final response using
/// `response-outparam.set`.
///
/// This will return an `HTTP-protocol-error` if `status` is not in the
/// range [100-199], or an `internal-error` if the implementation does not
/// support informational responses.
@unstable(feature = informational-outbound-responses)
send-informational: func(
status: u16,
headers: headers
) -> result<_, error-code>;

/// Set the value of the `response-outparam` to either send a response,
/// or indicate an error.
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/io/error.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:io@0.2.3;
package wasi:io@0.2.6;

@since(version = 0.2.0)
interface error {
Expand Down
Loading