Skip to content

Commit 2b8f212

Browse files
committed
Don't add the Date header if it already exists
the response can already contain a date header, either because it came from the async_h1::client::connect, or because the user set it manually. In that case don't add a second date header.
1 parent daaa9cc commit 2b8f212

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/server/encode.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ impl Encoder {
8484
)?;
8585
}
8686

87-
let date = fmt_http_date(std::time::SystemTime::now());
88-
std::io::Write::write_fmt(&mut self.head, format_args!("date: {}\r\n", date))?;
87+
if self.res.header(&http_types::headers::DATE).is_none() {
88+
let date = fmt_http_date(std::time::SystemTime::now());
89+
std::io::Write::write_fmt(&mut self.head, format_args!("date: {}\r\n", date))?;
90+
}
8991

9092
for (header, values) in self.res.iter() {
9193
for value in values.iter() {

0 commit comments

Comments
 (0)