Skip to content

Commit

Permalink
fix(http): skip zero length chunks when encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jul 17, 2017
1 parent 85c6bec commit d6da3f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/http/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/http/h1/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d6da3f7

Please sign in to comment.