Skip to content

Commit 9612c3b

Browse files
committed
Avoid additional allocation
1 parent cc41f42 commit 9612c3b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/client.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ where
143143
}
144144

145145
if res.header(&DATE).is_none() {
146-
let date = format!("Date: {}\r\n", fmt_http_date(std::time::SystemTime::now()));
147-
let value = HeaderValue::from_str(std::str::from_utf8(date.as_bytes())?)?;
148-
res.insert_header(DATE, value)?;
146+
let date = fmt_http_date(std::time::SystemTime::now());
147+
buf.write_all(b"Date: ").await?;
148+
buf.write_all(date.as_bytes()).await?;
149+
buf.write_all(b"\r\n").await?;
149150
}
150151

151152
let content_length = res.header(&CONTENT_LENGTH);

0 commit comments

Comments
 (0)