fix(client): fix panic when request body is empty string

This commit is contained in:
Sean McArthur
2017-12-26 13:07:28 -08:00
parent 11bf254b2c
commit bfb0f84d37
2 changed files with 39 additions and 1 deletions

View File

@@ -202,7 +202,15 @@ where
return Ok(Async::NotReady);
}
};
assert!(self.conn.write_body(Some(chunk))?.is_ready());
if self.conn.can_write_body() {
assert!(self.conn.write_body(Some(chunk))?.is_ready());
// This allows when chunk is `None`, or `Some([])`.
} else if chunk.as_ref().len() == 0 {
// ok
} else {
warn!("unexpected chunk when body cannot write");
}
} else {
return Ok(Async::NotReady);
}