Fixing small files fetching (#2742)

* Fixing small files fetching

* Fixing a case where tranfer encoding is not chunked
This commit is contained in:
Tomasz Drwięga
2016-10-20 12:57:48 +02:00
committed by Gav Wood
parent 7db42df1db
commit cd4e21e1b4
3 changed files with 21 additions and 7 deletions

View File

@@ -52,11 +52,14 @@ impl HttpProcessor {
}
}
#[cfg(test)]
pub fn status(&self) -> Option<&String> {
self.status.as_ref()
}
pub fn status_is_ok(&self) -> bool {
self.status == Some("HTTP/1.1 200 OK".into())
}
#[cfg(test)]
pub fn headers(&self) -> &[String] {
&self.headers
@@ -153,7 +156,7 @@ impl HttpProcessor {
}
try!(self.body_writer.write_all(self.buffer.get_ref()));
self.buffer_consume(len);
return Ok(());
return self.body_writer.flush();
},
State::WaitingForChunk => {
match self.find_break_index() {
@@ -189,7 +192,11 @@ impl HttpProcessor {
continue;
}
}
try!(self.body_writer.write_all(&self.buffer.get_ref()[0..left]));
{
let chunk = &self.buffer.get_ref()[0..left];
trace!("Writing chunk: {:?}", String::from_utf8_lossy(chunk));
try!(self.body_writer.write_all(chunk));
}
self.buffer_consume(left + BREAK_LEN);
self.set_state(State::WaitingForChunk);
@@ -200,7 +207,7 @@ impl HttpProcessor {
State::Finished => {
let len = self.buffer.get_ref().len();
self.buffer_consume(len);
return Ok(());
return self.body_writer.flush();
},
}
}