fix(http2): add Date header if not present for HTTP2 server responses
This commit is contained in:
@@ -2,6 +2,7 @@ use std::cell::RefCell;
|
||||
use std::fmt::{self, Write};
|
||||
use std::str;
|
||||
|
||||
use http::header::HeaderValue;
|
||||
use time::{self, Duration};
|
||||
|
||||
// "Sun, 06 Nov 1994 08:49:37 GMT".len()
|
||||
@@ -19,6 +20,15 @@ pub fn update() {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn update_and_header_value() -> HeaderValue {
|
||||
CACHED.with(|cache| {
|
||||
let mut cache = cache.borrow_mut();
|
||||
cache.check();
|
||||
HeaderValue::from_bytes(cache.buffer())
|
||||
.expect("Date format should be valid HeaderValue")
|
||||
})
|
||||
}
|
||||
|
||||
struct CachedDate {
|
||||
bytes: [u8; DATE_VALUE_LENGTH],
|
||||
pos: usize,
|
||||
|
||||
@@ -11,7 +11,7 @@ pub use self::io::Cursor; //TODO: move out of h1::io
|
||||
pub use self::io::MINIMUM_MAX_BUFFER_SIZE;
|
||||
|
||||
mod conn;
|
||||
mod date;
|
||||
pub(super) mod date;
|
||||
mod decode;
|
||||
pub(crate) mod dispatch;
|
||||
mod encode;
|
||||
|
||||
Reference in New Issue
Block a user