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;