@@ -356,7 +356,7 @@ mod extension {
356
356
}
357
357
}
358
358
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
360
360
// contain the following characters:
361
361
//
362
362
// ```
@@ -366,7 +366,7 @@ mod extension {
366
366
// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
367
367
// ```
368
368
//
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
370
370
//
371
371
// Note that this definition means that any &[u8] that consists solely of valid
372
372
// characters is also valid UTF-8 because the valid method characters are a
@@ -377,7 +377,7 @@ mod extension {
377
377
b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , // x
378
378
b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , b'\0' , // 1x
379
379
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
381
381
b'\0' , b'\0' , b'*' , b'+' , b'\0' , b'-' , b'.' , b'\0' , b'0' , b'1' , // 4x
382
382
b'2' , b'3' , b'4' , b'5' , b'6' , b'7' , b'8' , b'9' , b'\0' , b'\0' , // 5x
383
383
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 {
466
466
let long_method = "This_is_a_very_long_method.It_is_valid_but_unlikely." ;
467
467
assert_eq ! ( Method :: from_str( long_method) . unwrap( ) , long_method) ;
468
468
}
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
+ }
469
485
}
0 commit comments