Begin implementation of wasi-http (#5929)

* Integrate experimental HTTP into wasmtime.

* Reset Cargo.lock

* Switch to bail!, plumb options partially.

* Implement timeouts.

* Remove generated files & wasm, add Makefile

* Remove generated code textfile

* Update crates/wasi-http/Cargo.toml

Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com>

* Update crates/wasi-http/Cargo.toml

Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com>

* Extract streams from request/response.

* Fix read for len < buffer length.

* Formatting.

* types impl: swap todos for traps

* streams_impl: idioms, and swap todos for traps

* component impl: idioms, swap all unwraps for traps, swap all todos for traps

* http impl: idiom

* Remove an unnecessary mut.

* Remove an unsupported function.

* Switch to the tokio runtime for the HTTP request.

* Add a rust example.

* Update to latest wit definition

* Remove example code.

* wip: start writing a http test...

* finish writing the outbound request example

havent executed it yet

* better debug output

* wasi-http: some stubs required for rust rewrite of the example

* add wasi_http tests to test-programs

* CI: run the http tests

* Fix some warnings.

* bump new deps to latest releases (#3)

* Add tests for wasi-http to test-programs (#2)

* wip: start writing a http test...

* finish writing the outbound request example

havent executed it yet

* better debug output

* wasi-http: some stubs required for rust rewrite of the example

* add wasi_http tests to test-programs

* CI: run the http tests

* bump new deps to latest releases

h2 0.3.16
http 0.2.9
mio 0.8.6
openssl 0.10.48
openssl-sys 0.9.83
tokio 1.26.0

---------

Co-authored-by: Brendan Burns <bburns@microsoft.com>

* Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs

* Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs

* Update crates/test-programs/tests/http_tests/runtime/wasi_http_tests.rs

* wasi-http: fix cargo.toml file and publish script to work together (#4)

unfortunately, the publish script doesn't use a proper toml parser (in
order to not have any dependencies), so the whitespace has to be the
trivial expected case.

then, add wasi-http to the list of crates to publish.

* Update crates/test-programs/build.rs

* Switch to rustls

* Cleanups.

* Merge switch to rustls.

* Formatting

* Remove libssl install

* Fix tests.

* Rename wasi-http -> wasmtime-wasi-http

* prtest:full

Conditionalize TLS on riscv64gc.

* prtest:full

Fix formatting, also disable tls on s390x

* prtest:full

Add a path parameter to wit-bindgen, remove symlink.

* prtest:full

Fix tests for places where SSL isn't supported.

* Update crates/wasi-http/Cargo.toml

---------

Co-authored-by: Eduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com>
Co-authored-by: Pat Hickey <phickey@fastly.com>
Co-authored-by: Pat Hickey <pat@moreproductive.org>
This commit is contained in:
Brendan Burns
2023-04-05 13:33:03 -07:00
committed by GitHub
parent 7eb8914090
commit 2d34dbef4b
26 changed files with 2284 additions and 123 deletions

View File

@@ -66,6 +66,10 @@ pub const SUPPORTED_WASI_MODULES: &[(&str, &str)] = &[
"experimental-wasi-threads",
"enables support for the WASI threading API (experimental), see https://github.com/WebAssembly/wasi-threads",
),
(
"experimental-wasi-http",
"enables support for the WASI HTTP APIs (experimental), see https://github.com/WebAssembly/wasi-http",
),
];
fn init_file_per_thread_logger(prefix: &'static str) {
@@ -502,6 +506,7 @@ fn parse_wasi_modules(modules: &str) -> Result<WasiModules> {
"experimental-wasi-crypto" => Ok(wasi_modules.wasi_crypto = enable),
"experimental-wasi-nn" => Ok(wasi_modules.wasi_nn = enable),
"experimental-wasi-threads" => Ok(wasi_modules.wasi_threads = enable),
"experimental-wasi-http" => Ok(wasi_modules.wasi_http = enable),
"default" => bail!("'default' cannot be specified with other WASI modules"),
_ => bail!("unsupported WASI module '{}'", module),
};
@@ -536,6 +541,9 @@ pub struct WasiModules {
/// Enable the experimental wasi-threads implementation.
pub wasi_threads: bool,
/// Enable the experimental wasi-http implementation
pub wasi_http: bool,
}
impl Default for WasiModules {
@@ -545,6 +553,7 @@ impl Default for WasiModules {
wasi_crypto: false,
wasi_nn: false,
wasi_threads: false,
wasi_http: false,
}
}
}
@@ -557,6 +566,7 @@ impl WasiModules {
wasi_nn: false,
wasi_crypto: false,
wasi_threads: false,
wasi_http: false,
}
}
}
@@ -711,7 +721,8 @@ mod test {
wasi_common: true,
wasi_crypto: false,
wasi_nn: false,
wasi_threads: false
wasi_threads: false,
wasi_http: false,
}
);
}
@@ -725,7 +736,8 @@ mod test {
wasi_common: true,
wasi_crypto: false,
wasi_nn: false,
wasi_threads: false
wasi_threads: false,
wasi_http: false
}
);
}
@@ -743,7 +755,8 @@ mod test {
wasi_common: false,
wasi_crypto: false,
wasi_nn: true,
wasi_threads: false
wasi_threads: false,
wasi_http: false,
}
);
}
@@ -758,7 +771,8 @@ mod test {
wasi_common: false,
wasi_crypto: false,
wasi_nn: false,
wasi_threads: false
wasi_threads: false,
wasi_http: false,
}
);
}