From ab3e12f2b4a8a177421120bca0239a9e4cf3d874 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 20 Nov 2018 11:23:05 -0800 Subject: [PATCH] set server response version --- src/h1/codec.rs | 3 +++ tests/test_server.rs | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/h1/codec.rs b/src/h1/codec.rs index f9f455e5d..3174e78ea 100644 --- a/src/h1/codec.rs +++ b/src/h1/codec.rs @@ -149,6 +149,9 @@ impl Encoder for Codec { ) -> Result<(), Self::Error> { match item { Message::Item((mut res, length)) => { + // set response version + res.head_mut().version = self.version; + // connection status self.ctype = if let Some(ct) = res.head().ctype { if ct == ConnectionType::KeepAlive { diff --git a/tests/test_server.rs b/tests/test_server.rs index 16c65aac1..a153e584d 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -137,7 +137,7 @@ fn test_keepalive_http10_default_close() { let _ = stream.write_all(b"GET /test/tests/test HTTP/1.0\r\n\r\n"); let mut data = vec![0; 1024]; let _ = stream.read(&mut data); - assert_eq!(&data[..17], b"HTTP/1.1 200 OK\r\n"); + assert_eq!(&data[..17], b"HTTP/1.0 200 OK\r\n"); let mut data = vec![0; 1024]; let res = stream.read(&mut data).unwrap(); @@ -157,13 +157,13 @@ fn test_keepalive_http10() { .write_all(b"GET /test/tests/test HTTP/1.0\r\nconnection: keep-alive\r\n\r\n"); let mut data = vec![0; 1024]; let _ = stream.read(&mut data); - assert_eq!(&data[..17], b"HTTP/1.1 200 OK\r\n"); + assert_eq!(&data[..17], b"HTTP/1.0 200 OK\r\n"); let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test/tests/test HTTP/1.0\r\n\r\n"); let mut data = vec![0; 1024]; let _ = stream.read(&mut data); - assert_eq!(&data[..17], b"HTTP/1.1 200 OK\r\n"); + assert_eq!(&data[..17], b"HTTP/1.0 200 OK\r\n"); let mut data = vec![0; 1024]; let res = stream.read(&mut data).unwrap();