Skip to content

Commit ca5e520

Browse files
Eijebongseanmonstar
authored andcommitted
fix(http1): fix title-case option when header names have symbols
Don't eat the first character in a header name if it's not a letter. Same thing after a `-`
1 parent b058919 commit ca5e520

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/proto/h1/role.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,8 @@ fn title_case(dst: &mut Vec<u8>, name: &[u8]) {
943943
if let Some(c) = iter.next() {
944944
if *c >= b'a' && *c <= b'z' {
945945
dst.push(*c ^ b' ');
946+
} else {
947+
dst.push(*c);
946948
}
947949
}
948950

@@ -953,6 +955,8 @@ fn title_case(dst: &mut Vec<u8>, name: &[u8]) {
953955
if let Some(c) = iter.next() {
954956
if *c >= b'a' && *c <= b'z' {
955957
dst.push(*c ^ b' ');
958+
} else {
959+
dst.push(*c);
956960
}
957961
}
958962
}
@@ -1371,6 +1375,7 @@ mod tests {
13711375
let mut head = MessageHead::default();
13721376
head.headers.insert("content-length", HeaderValue::from_static("10"));
13731377
head.headers.insert("content-type", HeaderValue::from_static("application/json"));
1378+
head.headers.insert("*-*", HeaderValue::from_static("o_o"));
13741379

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

1384-
assert_eq!(vec, b"GET / HTTP/1.1\r\nContent-Length: 10\r\nContent-Type: application/json\r\n\r\n".to_vec());
1389+
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());
13851390
}
13861391

13871392
#[test]

0 commit comments

Comments
 (0)