@@ -356,7 +356,7 @@ mod extension {
356356 }
357357 }
358358
359- // From the HTTP spec section 5.1 .1, the HTTP method is case-sensitive and can
359+ // From the RFC 9110 HTTP Semantics, section 9 .1, the HTTP method is case-sensitive and can
360360 // contain the following characters:
361361 //
362362 // ```
@@ -366,7 +366,7 @@ mod extension {
366366 // "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
367367 // ```
368368 //
369- // https://www.w3 .org/Protocols/HTTP/1.1/draft-ietf-http-v11-spec-01#Method
369+ // https://datatracker.ietf .org/doc/html/rfc9110#section-9.1
370370 //
371371 // Note that this definition means that any &[u8] that consists solely of valid
372372 // characters is also valid UTF-8 because the valid method characters are a
@@ -377,7 +377,7 @@ mod extension {
377377 b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , // x
378378 b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , // 1x
379379 b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , // 2x
380- b'\0' , b'\0' , b'\0' , b'!' , b'\0' , b'\0 ', b'\0 ', b'\0 ', b'\0 ', b'\0 ' , // 3x
380+ b'\0' , b'\0' , b'\0' , b'!' , b'\0' , b'# ', b'$ ', b'% ', b'& ', b'\' ' , // 3x
381381 b'\0' , b'\0' , b'*' , b'+' , b'\0' , b'-' , b'.' , b'\0' , b'0' , b'1' , // 4x
382382 b'2' , b'3' , b'4' , b'5' , b'6' , b'7' , b'8' , b'9' , b'\0' , b'\0' , // 5x
383383 b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'A' , b'B' , b'C' , b'D' , b'E' , // 6x
@@ -466,4 +466,20 @@ mod test {
466466 let long_method = "This_is_a_very_long_method.It_is_valid_but_unlikely." ;
467467 assert_eq ! ( Method :: from_str( long_method) . unwrap( ) , long_method) ;
468468 }
469+
470+ #[ test]
471+ fn test_extension_method_chars ( ) {
472+ const VALID_METHOD_CHARS : & str =
473+ "!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;
474+
475+ for c in VALID_METHOD_CHARS . chars ( ) {
476+ let c = c. to_string ( ) ;
477+
478+ assert_eq ! (
479+ Method :: from_str( & c) . unwrap( ) ,
480+ c. as_str( ) ,
481+ "testing {c} is a valid method character"
482+ ) ;
483+ }
484+ }
469485}
0 commit comments