From 9070d59ea87f97feb70e67a12e84b81192477538 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 6 Jul 2018 08:11:36 +0600 Subject: [PATCH] do not read head payload --- src/client/pipeline.rs | 4 ++++ tests/test_server.rs | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/pipeline.rs b/src/client/pipeline.rs index fbbce4546..9828478cd 100644 --- a/src/client/pipeline.rs +++ b/src/client/pipeline.rs @@ -17,6 +17,7 @@ use context::{ActorHttpContext, Frame}; use error::Error; use error::PayloadError; use header::ContentEncoding; +use http::Method; use httpmessage::HttpMessage; use server::input::PayloadStream; use server::WriterState; @@ -212,6 +213,9 @@ impl Future for SendRequest { match pl.parse() { Ok(Async::Ready(mut resp)) => { + if self.req.method() == &Method::HEAD { + pl.parser.take(); + } resp.set_pipeline(pl); return Ok(Async::Ready(resp)); } diff --git a/tests/test_server.rs b/tests/test_server.rs index 4fb73a6a5..4c50434c2 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -368,8 +368,8 @@ fn test_head_empty() { } // read response - // let bytes = srv.execute(response.body()).unwrap(); - // assert!(bytes.is_empty()); + let bytes = srv.execute(response.body()).unwrap(); + assert!(bytes.is_empty()); } #[test] @@ -396,8 +396,8 @@ fn test_head_binary() { } // read response - //let bytes = srv.execute(response.body()).unwrap(); - //assert!(bytes.is_empty()); + let bytes = srv.execute(response.body()).unwrap(); + assert!(bytes.is_empty()); } #[test]