Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wasi-streams in the wasi-http implementation #7056

Merged
merged 62 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
2a1d46b
Start refactoring wasi-http
elliottt Sep 13, 2023
119c17a
Checkpoint
elliottt Sep 14, 2023
5f13f1c
Initial implementation of response future handling
elliottt Sep 14, 2023
96f9c71
Lazily initialize response headers and body
elliottt Sep 14, 2023
6546205
make wasmtime-wasi-http compile
Sep 14, 2023
21e09b8
wasi-http wit: make a way to reject outgoing-request in outgoing-handler
Sep 14, 2023
48ba40e
wasi: sync wit from wasi-http
Sep 14, 2023
a9a4dad
outgoing handler impl: report errors to userland
Sep 14, 2023
0718d60
test-programs: get wasi-http-components kicking over, delete modules …
Sep 14, 2023
1e2bfc6
Process headers
elliottt Sep 14, 2023
5d412e3
Add HostIncomingBody::new
elliottt Sep 14, 2023
7a79086
Add trailers functions
elliottt Sep 14, 2023
c2e7e74
Add TODO for body task outline
elliottt Sep 15, 2023
b663678
Rework incoming-response-consume to return a future-trailers value as…
elliottt Sep 15, 2023
a2250b3
Fix the wit
elliottt Sep 15, 2023
f2795b0
First cut at the worker loop
elliottt Sep 15, 2023
ac8cf02
wasi-http: change how we represent bodies/trailers, and annotate own/…
Sep 15, 2023
ef3ce0a
Update types_impl.rs for wit changes
elliottt Sep 15, 2023
7f6ad99
Split body management into its own module
elliottt Sep 15, 2023
cb6981b
Checkpoint
elliottt Sep 15, 2023
fc6b6f4
more work on incoming body and future trailers
Sep 15, 2023
41379a2
Fill out some more functions
elliottt Sep 15, 2023
39f93f0
Implement future-trailers-{subscribe,get}
elliottt Sep 18, 2023
ebaa0b6
Implement drop-future-trailers
elliottt Sep 18, 2023
a4f69b4
Rework fields, but make the borrow checker mad
elliottt Sep 18, 2023
b44fd65
Fix borrow error
alexcrichton Sep 18, 2023
15a9ae5
wasi-http-tests: fix build
Sep 18, 2023
3bbcbdf
test-runner: report errors with stdout/stderr properly
Sep 18, 2023
b81e7b7
fix two trivial wasi-http tests
Sep 18, 2023
5bf7f12
Remove unnecessary drops
elliottt Sep 18, 2023
91f9b98
Convert a `bail!` to a `todo!`
elliottt Sep 18, 2023
486e4f8
Remove a TODO that documented the body worker structure
elliottt Sep 18, 2023
a38546e
fill in a bunch more of OutputBody
Sep 19, 2023
b57c0f4
Remove the custom FrameFut future in favor of using http_body_util
elliottt Sep 19, 2023
be93779
Move the outgoing body types to body.rs
elliottt Sep 19, 2023
b8b255b
Rework the handling of outgoing bodies
elliottt Sep 19, 2023
33a1ee2
Fix the `outgoing request get` test
elliottt Sep 19, 2023
bf4b148
Avoid deadlocking the post tests
elliottt Sep 19, 2023
836e9f8
future_incoming_request_get shouldn't delete the resource
elliottt Sep 19, 2023
e3e9940
Fix the invalid_dnsname test
elliottt Sep 19, 2023
001f249
implement drop-future-incoming-response
elliottt Sep 19, 2023
e2cb195
Fix invalid_port and invalid_dnsname tests
elliottt Sep 19, 2023
d6f15c2
Fix the post test
elliottt Sep 19, 2023
83d43ae
Passing a too large string to println! caused the large post test to …
elliottt Sep 19, 2023
f953b06
Format
elliottt Sep 19, 2023
27c5ac5
Plumb through `between_bytes_timeout`
elliottt Sep 19, 2023
43ff3b9
Downgrade hyper
elliottt Sep 20, 2023
a6d57f0
Revert "Downgrade hyper"
elliottt Sep 20, 2023
f1cc65e
Restore old https connection setup
elliottt Sep 20, 2023
e3addd4
Sync the wasi and wasi-http http deps
elliottt Sep 20, 2023
008f85a
Fix tests
elliottt Sep 20, 2023
ccab9e5
Fix wasi-http integration
elliottt Sep 20, 2023
93dc947
sync implementation of wasi-http
elliottt Sep 20, 2023
27ef314
Slightly more robust error checking
elliottt Sep 20, 2023
3c13cf3
Ignore the wasi-http cli test
elliottt Sep 21, 2023
ab991fd
Consistent ignore attributes between sync and async tests
elliottt Sep 21, 2023
fc58a2e
Fix doc errors
elliottt Sep 21, 2023
6810c9f
code motion: introduce intermediate `HostIncomingBodyBuilder` rather …
Sep 21, 2023
5a24679
explain design
Sep 21, 2023
4739421
Turn FieldMap into a type synonym
elliottt Sep 21, 2023
39cbda9
Tidy up some future state (#7073)
alexcrichton Sep 21, 2023
6506d10
body HostInputStream: report runtime errors with StreamRuntimeError
Sep 21, 2023
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
13 changes: 7 additions & 6 deletions crates/test-programs/tests/wasi-http-components-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ impl WasiView for Ctx {
}

impl WasiHttpView for Ctx {
fn http_ctx(&self) -> &WasiHttpCtx {
&self.http
}
fn http_ctx_mut(&mut self) -> &mut WasiHttpCtx {
fn ctx(&mut self) -> &mut WasiHttpCtx {
&mut self.http
}

fn table(&mut self) -> &mut Table {
&mut self.table
}
}

fn instantiate_component(
Expand All @@ -60,7 +61,7 @@ fn instantiate_component(
) -> Result<(Store<Ctx>, Command), anyhow::Error> {
let mut linker = Linker::new(&ENGINE);
add_to_linker(&mut linker)?;
wasmtime_wasi_http::proxy::sync::add_to_linker(&mut linker)?;
wasmtime_wasi_http::proxy::add_to_linker(&mut linker)?;

let mut store = Store::new(&ENGINE, ctx);

Expand All @@ -84,7 +85,7 @@ fn run(name: &str) -> anyhow::Result<()> {
builder.env(var, val);
}
let wasi = builder.build(&mut table)?;
let http = WasiHttpCtx::new();
let http = WasiHttpCtx {};

let (mut store, command) = instantiate_component(component, Ctx { table, wasi, http })?;
command
Expand Down
18 changes: 7 additions & 11 deletions crates/test-programs/tests/wasi-http-components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ impl WasiView for Ctx {
}

impl WasiHttpView for Ctx {
fn http_ctx(&self) -> &WasiHttpCtx {
&self.http
fn table(&mut self) -> &mut Table {
&mut self.table
}
fn http_ctx_mut(&mut self) -> &mut WasiHttpCtx {
fn ctx(&mut self) -> &mut WasiHttpCtx {
&mut self.http
}
}
Expand Down Expand Up @@ -85,16 +85,11 @@ async fn run(name: &str) -> anyhow::Result<()> {
builder.env(var, val);
}
let wasi = builder.build(&mut table)?;
let http = WasiHttpCtx::new();
let http = WasiHttpCtx;

let (mut store, command) =
instantiate_component(component, Ctx { table, wasi, http }).await?;
command
.wasi_cli_run()
.call_run(&mut store)
.await?
.map_err(|()| anyhow::anyhow!("run returned a failure"))?;
Ok(())
command.wasi_cli_run().call_run(&mut store).await
};
r.map_err(move |trap: anyhow::Error| {
let stdout = stdout.try_into_inner().expect("single ref to stdout");
Expand All @@ -109,7 +104,8 @@ async fn run(name: &str) -> anyhow::Result<()> {
"error while testing wasi-tests {} with http-components",
name
))
})?;
})?
.map_err(|()| anyhow::anyhow!("run returned an error"))?;
Ok(())
}

Expand Down
196 changes: 0 additions & 196 deletions crates/test-programs/tests/wasi-http-modules.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ async fn run() {
)
.await;

let error = res.unwrap_err();
assert_eq!(error.to_string(), "Error::InvalidUrl(\"invalid dnsname\")");
let error = res.unwrap_err().to_string();
assert!(error.starts_with("Error::InvalidUrl(\"failed to lookup address information:"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn run() {

let error = res.unwrap_err().to_string();
if error.ne("Error::ProtocolError(\"invalid HTTP version parsed\")")
&& error.ne("Error::ProtocolError(\"operation was canceled\")")
&& !error.starts_with("Error::ProtocolError(\"operation was canceled")
{
panic!(
r#"assertion failed: `(left == right)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn run() {
.context("localhost:3000 /post large")
.unwrap();

println!("localhost:3000 /post large: {res:?}");
println!("localhost:3000 /post large: {}", res.status);
assert_eq!(res.status, 200);
let method = res.header("x-wasmtime-test-method").unwrap();
assert_eq!(std::str::from_utf8(method).unwrap(), "POST");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ async fn run() {
assert_eq!(res.status, 200);
let method = res.header("x-wasmtime-test-method").unwrap();
assert_eq!(std::str::from_utf8(method).unwrap(), "POST");
assert_eq!(res.body, b"{\"foo\": \"bar\"}");
assert_eq!(res.body, b"{\"foo\": \"bar\"}", "invalid body returned");
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ async fn run() {
let error = res.unwrap_err();
assert_eq!(
error.to_string(),
"Error::InvalidUrl(\"unknown method OTHER\")"
"Error::Invalid(\"unknown method OTHER\")"
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ async fn run() {
let error = res.unwrap_err();
assert_eq!(
error.to_string(),
"Error::InvalidUrl(\"unsupported scheme WS\")"
"Error::Invalid(\"unsupported scheme WS\")"
);
}
Loading
Loading