Skip to content

Commit 1e82443

Browse files
authored
Remove the check for ':' when setting authority in wasi-http. (#11145)
* Remove the check for ':' when setting authority in wasi-http. Authorities can have `:` in them when they are IPV6 addresses. Signed-off-by: Ryan Levick <ryan.levick@fermyon.com> * Add test for allowing IPv6 authority Signed-off-by: Ryan Levick <ryan.levick@fermyon.com> --------- Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
1 parent b4d2bff commit 1e82443

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

crates/test-programs/src/bin/http_outbound_request_response_build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ fn main() {
4848
.is_err()
4949
);
5050

51-
assert!(req.set_authority(Some("bad-port:99999")).is_err());
5251
assert!(req.set_authority(Some("bad-\nhost")).is_err());
53-
assert!(req.set_authority(Some("too-many-ports:80:80:80")).is_err());
52+
// IPv6 addresses with and without a port should be allowed
53+
assert!(req.set_authority(Some("[::]:443")).is_ok());
54+
assert!(req.set_authority(Some("[::]")).is_ok());
5455

5556
assert!(
5657
req.set_scheme(Some(&http_types::Scheme::Other("bad\nscheme".to_string())))

crates/wasi-http/src/types_impl.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,7 @@ where
511511
let req = self.table().get_mut(&request)?;
512512

513513
if let Some(s) = authority.as_ref() {
514-
let auth = match http::uri::Authority::from_str(s.as_str()) {
515-
Ok(auth) => auth,
516-
Err(_) => return Ok(Err(())),
517-
};
518-
519-
if s.contains(':') && auth.port_u16().is_none() {
514+
if let Err(_) = http::uri::Authority::from_str(s.as_str()) {
520515
return Ok(Err(()));
521516
}
522517
}

0 commit comments

Comments
 (0)