async-h1
async-h1 copied to clipboard
Decode inserts malformed date header
https://github.com/http-rs/async-h1/blob/dffae5fb497dbead73c3d2c87f4d5f9e6e75b2b3/src/client/decode.rs#L74
I'm seeing date header values like
Header date -> [
"date: Wed, 01 Sep 2021 17:42:04 GMT\r\n",
]
Where date: and \r\n are both included in the value of the header.
I think
if res.header(DATE).is_none() {
let date = fmt_http_date(std::time::SystemTime::now());
res.insert_header(DATE, &format!("date: {}\r\n", date)[..]);
}
Should be
if res.header(DATE).is_none() {
let date = fmt_http_date(std::time::SystemTime::now());
res.insert_header(DATE, &format!("{}", date)[..]);
}
Other headers for reference
Header date -> [
"date: Wed, 01 Sep 2021 17:42:04 GMT\r\n",
]
Header content-type -> [
"application/json",
]
Header content-length -> [
"211",
]
@brosander ooph, yes that's a great catch! Your suggested fix also makes a lot of sense. Would you be willing to file a PR implementing that?