diff --git a/CHANGES.md b/CHANGES.md index c4bb1ea7478..d95ea779981 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,9 +8,11 @@ * Allow to set client websocket handshake timeout +* Refactor `TestServer` configuration + * Fix server websockets big payloads support -* Refactor `TestServer` configuration +* Fix http/2 date header generation ## 0.4.9 (2018-03-16) diff --git a/src/server/h2writer.rs b/src/server/h2writer.rs index 738a0593fe4..32f70961bcd 100644 --- a/src/server/h2writer.rs +++ b/src/server/h2writer.rs @@ -90,7 +90,7 @@ impl Writer for H2Writer { // 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()); } diff --git a/src/server/settings.rs b/src/server/settings.rs index 7f901a71b15..4255755f448 100644 --- a/src/server/settings.rs +++ b/src/server/settings.rs @@ -183,6 +183,10 @@ impl WorkerSettings { 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 { diff --git a/tests/test_server.rs b/tests/test_server.rs index 9cc09d029e5..10f71ab2f52 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -742,8 +742,8 @@ fn test_h2() { }) }) }); - let _res = core.run(tcp); - // assert_eq!(res.unwrap(), Bytes::from_static(STR.as_ref())); + let res = core.run(tcp); + assert_eq!(res.unwrap(), Bytes::from_static(STR.as_ref())); } #[test]