Skip to content

Commit

Permalink
Allow characters #, $, %, &, ' in HTTP method
Browse files Browse the repository at this point in the history
  • Loading branch information
franfastly committed Aug 7, 2024
1 parent f4e8c0c commit a7a91aa
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ mod extension {
b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', // x
b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', // 1x
b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', // 2x
b'\0', b'\0', b'\0', b'!', b'\0', b'\0', b'\0', b'\0', b'\0', b'\0', // 3x
b'\0', b'\0', b'\0', b'!', b'\0', b'#', b'$', b'%', b'&', b'\'', // 3x
b'\0', b'\0', b'*', b'+', b'\0', b'-', b'.', b'\0', b'0', b'1', // 4x
b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'\0', b'\0', // 5x
b'\0', b'\0', b'\0', b'\0', b'\0', b'A', b'B', b'C', b'D', b'E', // 6x
Expand Down Expand Up @@ -466,4 +466,20 @@ mod test {
let long_method = "This_is_a_very_long_method.It_is_valid_but_unlikely.";
assert_eq!(Method::from_str(long_method).unwrap(), long_method);
}

#[test]
fn test_extension_method_chars() {
const VALID_METHOD_CHARS: &str =
"!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

for c in VALID_METHOD_CHARS.chars() {
let c = c.to_string();

assert_eq!(
Method::from_str(&c).unwrap(),
c.as_str(),
"testing {c} is a valid method character"
);
}
}
}

0 comments on commit a7a91aa

Please sign in to comment.