A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Use the scheme of the connect, not the request target (#14915)
Alex Crichton54501e9d94bf
diff --git a/crates/wasi-http/src/handler.rs b/crates/wasi-http/src/handler.rsindex 96eb1e6eff..45e20780d2 100644--- a/crates/wasi-http/src/handler.rs+++ b/crates/wasi-http/src/handler.rs@@ -1015,7 +1015,6 @@ impl<'a, T: Send> Prepared<'a, T> {..} = parts;let http::uri::Parts {- scheme,authority,path_and_query,..@@ -1031,12 +1030,11 @@ impl<'a, T: Send> Prepared<'a, T> {};let hooks = view(store.data_mut()).hooks;let headers = crate::FieldMap::new_immutable(hooks, request_headers);- // `serve` speaks plaintext HTTP, so that is the scheme of a- // request which does not name one.- let scheme = scheme.unwrap_or(http::uri::Scheme::HTTP);+ // `serve` speaks plaintext HTTP, so that is the scheme of every+ // request, whatever scheme its request target names (as in p2).let (request, request_io_result) = p3::Request::new(method,- Some(scheme),+ Some(http::uri::Scheme::HTTP),authority,path_and_query,headers,diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rsindex 7f65b9f3b2..a55d01268c 100644--- a/tests/all/cli_tests.rs+++ b/tests/all/cli_tests.rs@@ -2267,6 +2267,18 @@ start a print 1234.await?;assert!(resp.status().is_success());+ // The scheme is that of the connection, not of an absolute-form+ // request target.+ let resp = server+ .send_request(+ hyper::Request::builder()+ .uri("https://localhost/")+ .body(String::new())+ .context("failed to make request")?,+ )+ .await?;+ assert!(resp.status().is_success());+Ok(())}