Skip to content

Commit

Permalink
fix(http1): fix title-case option when header names have symbols
Browse files Browse the repository at this point in the history
Don't eat the first character in a header name if it's not a letter. Same thing after a `-`
  • Loading branch information
Eijebong authored and seanmonstar committed Sep 15, 2018
1 parent b058919 commit ca5e520
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/proto/h1/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,8 @@ fn title_case(dst: &mut Vec<u8>, name: &[u8]) {
if let Some(c) = iter.next() {
if *c >= b'a' && *c <= b'z' {
dst.push(*c ^ b' ');
} else {
dst.push(*c);
}
}

Expand All @@ -953,6 +955,8 @@ fn title_case(dst: &mut Vec<u8>, name: &[u8]) {
if let Some(c) = iter.next() {
if *c >= b'a' && *c <= b'z' {
dst.push(*c ^ b' ');
} else {
dst.push(*c);
}
}
}
Expand Down Expand Up @@ -1371,6 +1375,7 @@ mod tests {
let mut head = MessageHead::default();
head.headers.insert("content-length", HeaderValue::from_static("10"));
head.headers.insert("content-type", HeaderValue::from_static("application/json"));
head.headers.insert("*-*", HeaderValue::from_static("o_o"));

let mut vec = Vec::new();
Client::encode(Encode {
Expand All @@ -1381,7 +1386,7 @@ mod tests {
title_case_headers: true,
}, &mut vec).unwrap();

assert_eq!(vec, b"GET / HTTP/1.1\r\nContent-Length: 10\r\nContent-Type: application/json\r\n\r\n".to_vec());
assert_eq!(vec, b"GET / HTTP/1.1\r\nContent-Length: 10\r\nContent-Type: application/json\r\n*-*: o_o\r\n\r\n".to_vec());
}

#[test]
Expand Down

0 comments on commit ca5e520

Please sign in to comment.