fix(http): fix encoding when buffer is full

This commit is contained in:
Sean McArthur
2017-07-17 11:19:32 -07:00
parent d6da3f7b40
commit fc5b9cce31
3 changed files with 12 additions and 2 deletions

View File

@@ -54,9 +54,12 @@ impl Encoder {
chunked.encode(w, msg)
},
Kind::Length(ref mut remaining) => {
if msg.is_empty() {
return Ok(0);
}
let n = {
let max = cmp::min(*remaining as usize, msg.len());
trace!("sized write, len = {}", max);
trace!("sized write, len = {}, remaining = {}", max, remaining);
let slice = &msg[..max];
try!(w.write_atomic(&[slice]))