Skip to content

Commit 0ea5f5c

Browse files
committed
Send the date header from the server
1 parent ff87f21 commit 0ea5f5c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/server.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::time::Duration;
1414
use std::pin::Pin;
1515

1616
use crate::{Exception, MAX_HEADERS};
17+
use crate::date::fmt_http_date;
1718

1819
pub async fn connect<R, W, F, Fut>(
1920
addr: &str,
@@ -159,6 +160,9 @@ pub async fn encode(res: Response) -> io::Result<Encoder> {
159160
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer
160161
}
161162

163+
let date = fmt_http_date(std::time::SystemTime::now());
164+
std::io::Write::write_fmt(&mut buf, format_args!("Date: {}\r\n", date))?;
165+
162166
for (header, value) in res.headers().iter() {
163167
std::io::Write::write_fmt(&mut buf, format_args!("{}: {}\r\n", header.as_str(), value))?
164168
}

0 commit comments

Comments
 (0)