Skip to content

Commit 432ecfb

Browse files
authored
Merge pull request #58 from yoshuawuyts/header-value-case
Don't lowercase header values
2 parents cb0c863 + 728dcb4 commit 432ecfb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/headers/header_value.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ impl HeaderValue {
1515
///
1616
/// # Error
1717
///
18-
/// This function will error if the string
18+
/// This function will error if the string is not a valid ASCII.
1919
pub fn from_ascii(bytes: &[u8]) -> Result<Self, ParseError> {
2020
if !bytes.is_ascii() {
2121
return Err(ParseError::new());
2222
}
2323

2424
// This is permitted because ASCII is valid UTF-8, and we just checked that.
25-
let string = unsafe { String::from_utf8_unchecked(bytes.to_ascii_lowercase()) };
25+
let string = unsafe { String::from_utf8_unchecked(bytes.to_vec()) };
2626
Ok(Self { inner: string })
2727
}
2828

@@ -75,13 +75,13 @@ impl FromStr for HeaderValue {
7575

7676
/// Create a new `HeaderValue`.
7777
///
78-
/// This checks it's valid ASCII, and lowercases it.
78+
/// This checks it's valid ASCII.
7979
fn from_str(s: &str) -> Result<Self, Self::Err> {
8080
if !s.is_ascii() {
8181
return Err(ParseError::new());
8282
}
8383
Ok(Self {
84-
inner: s.to_ascii_lowercase(),
84+
inner: String::from(s),
8585
})
8686
}
8787
}

0 commit comments

Comments
 (0)