Skip to content

Commit d6da3f7

Browse files
committed
fix(http): skip zero length chunks when encoding
1 parent 85c6bec commit d6da3f7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/http/conn.rs

+4
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ where I: AsyncRead + AsyncWrite,
269269
return Ok(AsyncSink::NotReady(chunk));
270270
}
271271
if let Some(chunk) = chunk {
272+
if chunk.as_ref().is_empty() {
273+
return Ok(AsyncSink::Ready);
274+
}
275+
272276
let mut cursor = Cursor::new(chunk);
273277
match encoder.encode(&mut self.io, cursor.buf()) {
274278
Ok(n) => {

src/http/h1/encode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl Encoder {
6363
};
6464

6565
if n == 0 {
66-
return Err(io::Error::new(io::ErrorKind::WouldBlock, "would block"));
66+
return Err(io::Error::new(io::ErrorKind::WriteZero, "write zero"));
6767
}
6868

6969
*remaining -= n as u64;

0 commit comments

Comments
 (0)