From d6da3f7b40550b425f760d0d331807feff9114fd Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 17 Jul 2017 10:41:36 -0700 Subject: [PATCH] fix(http): skip zero length chunks when encoding --- src/http/conn.rs | 4 ++++ src/http/h1/encode.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/http/conn.rs b/src/http/conn.rs index ed79b09e4e..b3eb699956 100644 --- a/src/http/conn.rs +++ b/src/http/conn.rs @@ -269,6 +269,10 @@ where I: AsyncRead + AsyncWrite, return Ok(AsyncSink::NotReady(chunk)); } if let Some(chunk) = chunk { + if chunk.as_ref().is_empty() { + return Ok(AsyncSink::Ready); + } + let mut cursor = Cursor::new(chunk); match encoder.encode(&mut self.io, cursor.buf()) { Ok(n) => { diff --git a/src/http/h1/encode.rs b/src/http/h1/encode.rs index 4b8bab5b2e..ed643898cc 100644 --- a/src/http/h1/encode.rs +++ b/src/http/h1/encode.rs @@ -63,7 +63,7 @@ impl Encoder { }; if n == 0 { - return Err(io::Error::new(io::ErrorKind::WouldBlock, "would block")); + return Err(io::Error::new(io::ErrorKind::WriteZero, "write zero")); } *remaining -= n as u64;