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();