The documentation of HeaderValue::from_str says that:
|
/// If the argument contains invalid header value characters, an error is |
|
/// returned. Only visible ASCII characters (32-127) are permitted. Use |
|
/// `from_bytes` to create a `HeaderValue` that includes opaque octets |
|
/// (128-255). |
So I would expect this function to return an error when I pass it a non-ascii utf8 string which contains byte values in the 128-255 range. However the result is success.
Playground link
let x = http::header::HeaderValue::from_str("ñ");
panic!("{:?}", x);
thread 'main' panicked at 'Ok("\xc3\xb1")', src/main.rs:3:5
The documentation of
HeaderValue::from_strsays that:http/src/header/value.rs
Lines 101 to 104 in abe6512
So I would expect this function to return an error when I pass it a non-ascii utf8 string which contains byte values in the 128-255 range. However the result is success.
Playground link