forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasi-http: add the port to authority when opening a TCP connection (b…
…ytecodealliance#8671) * wasi-http: add the port to authority when opening a TCP connection * Ignore test on riscv64 and s390x --------- Co-authored-by: Alex Crichton <[email protected]>
- Loading branch information
1 parent
ac743dd
commit f1fe2af
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
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,42 @@ | ||
use test_programs::wasi::http::types::{ | ||
Headers, IncomingRequest, OutgoingBody, OutgoingResponse, ResponseOutparam, | ||
}; | ||
|
||
struct T; | ||
|
||
test_programs::proxy::export!(T); | ||
|
||
impl test_programs::proxy::exports::wasi::http::incoming_handler::Guest for T { | ||
fn handle(request: IncomingRequest, outparam: ResponseOutparam) { | ||
let res = test_programs::http::request( | ||
request.method(), | ||
request.scheme().unwrap(), | ||
request.authority().unwrap().as_str(), | ||
request.path_with_query().unwrap().as_str(), | ||
None, | ||
None, | ||
None, | ||
None, | ||
None, | ||
) | ||
.unwrap(); | ||
|
||
let hdrs = Headers::from_list(&res.headers).unwrap(); | ||
let resp = OutgoingResponse::new(hdrs); | ||
resp.set_status_code(res.status).expect("status code"); | ||
let body = resp.body().expect("outgoing response"); | ||
|
||
ResponseOutparam::set(outparam, Ok(resp)); | ||
|
||
let out = body.write().expect("outgoing stream"); | ||
out.blocking_write_and_flush(res.body.as_ref()) | ||
.expect("writing response"); | ||
|
||
drop(out); | ||
OutgoingBody::finish(body, None).expect("outgoing-body.finish"); | ||
} | ||
} | ||
|
||
// Technically this should not be here for a proxy, but given the current | ||
// framework for tests it's required since this file is built as a `bin` | ||
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