1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 02:19:22 +02:00

Fix http/2 date header generation

This commit is contained in:
Nikolay Kim
2018-03-20 11:40:05 -07:00
parent 978091cedb
commit c4f4cadb43
4 changed files with 10 additions and 4 deletions

View File

@ -90,7 +90,7 @@ impl<H: 'static> Writer for H2Writer<H> {
// using helpers::date is quite a lot faster
if !msg.headers().contains_key(DATE) {
let mut bytes = BytesMut::with_capacity(29);
self.settings.set_date(&mut bytes);
self.settings.set_date_simple(&mut bytes);
msg.headers_mut().insert(DATE, HeaderValue::try_from(bytes.freeze()).unwrap());
}

View File

@ -183,6 +183,10 @@ impl<H> WorkerSettings<H> {
buf[35..].copy_from_slice(b"\r\n\r\n");
dst.extend_from_slice(&buf);
}
pub fn set_date_simple(&self, dst: &mut BytesMut) {
dst.extend_from_slice(&(unsafe{&*self.date.get()}.bytes));
}
}
struct Date {