-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This commit is aimed at fixing an accidental regression from #8861 where the `wasmtime serve` subcommand stopped reporting some instances of authority and scheme. After discussion in #8878 the new logic implemented is: * Creation of an incoming request now explicitly requires specifying a scheme which is out-of-band information about how the surrounding server received the request. * The authority is stored separately within a request and is inferred from the URI's authority or the `Host` header if present. If neither are present then an error is returned. Closes #8878
- Loading branch information
1 parent
72fe1de
commit 0bbdbc4
Showing
7 changed files
with
96 additions
and
34 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
crates/test-programs/src/bin/cli_serve_authority_and_scheme.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use test_programs::proxy; | ||
use test_programs::wasi::http::types::{ | ||
Fields, IncomingRequest, OutgoingResponse, ResponseOutparam, Scheme, | ||
}; | ||
|
||
struct T; | ||
|
||
proxy::export!(T); | ||
|
||
impl proxy::exports::wasi::http::incoming_handler::Guest for T { | ||
fn handle(request: IncomingRequest, outparam: ResponseOutparam) { | ||
let authority = request.authority(); | ||
let scheme = request.scheme(); | ||
|
||
assert_eq!(authority.as_deref(), Some("localhost")); | ||
assert!( | ||
matches!(scheme, Some(Scheme::Http)), | ||
"bad scheme: {scheme:?}", | ||
); | ||
|
||
let resp = OutgoingResponse::new(Fields::new()); | ||
ResponseOutparam::set(outparam, Ok(resp)); | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters