Skip to content

Commit c248ac0

Browse files
committed
Allow empty authority
This is copy of: hyperium#698
1 parent f4e8c0c commit c248ac0

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/uri/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,6 @@ fn parse_full(mut s: Bytes) -> Result<Uri, InvalidUri> {
862862
});
863863
}
864864

865-
// Authority is required when absolute
866-
if authority_end == 0 {
867-
return Err(ErrorKind::InvalidFormat.into());
868-
}
869-
870865
let authority = s.split_to(authority_end);
871866
let authority = Authority {
872867
data: unsafe { ByteStr::from_utf8_unchecked(authority) },

src/uri/tests.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,19 @@ test_parse! {
384384
port = Port::from_str("8008").ok(),
385385
}
386386

387+
test_parse! {
388+
test_file_no_host,
389+
"file:///some/path",
390+
[],
391+
392+
scheme = part!("file"),
393+
authority = None,
394+
host = None,
395+
path = "/some/path",
396+
query = None,
397+
port = None,
398+
}
399+
387400
test_parse! {
388401
test_percentage_encoded_path,
389402
"/echo/abcdefgh_i-j%20/abcdefg_i-j%20478",
@@ -419,7 +432,6 @@ fn test_uri_parse_error() {
419432
Uri::from_str(s).unwrap_err();
420433
}
421434

422-
err("http://");
423435
err("htt:p//host");
424436
err("hyper.rs/");
425437
err("hyper.rs?key=val");

0 commit comments

Comments
 (0)