1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 01:32:57 +01:00

Fix Client Request with custom Body Stream halting on certain size requests #176

This commit is contained in:
Nikolay Kim 2018-04-15 10:22:09 -07:00
parent a9ea649348
commit 58cc0dfbc5
3 changed files with 14 additions and 5 deletions

View File

@ -9,6 +9,8 @@
* Fix StaticFiles does not support percent encoded paths #177 * Fix StaticFiles does not support percent encoded paths #177
* Fix Client Request with custom Body Stream halting on certain size requests #176
## 0.5.1 (2018-04-12) ## 0.5.1 (2018-04-12)

View File

@ -184,6 +184,7 @@ impl Future for SendRequest {
parser: Some(HttpResponseParser::default()), parser: Some(HttpResponseParser::default()),
parser_buf: BytesMut::new(), parser_buf: BytesMut::new(),
disconnected: false, disconnected: false,
body_completed: false,
drain: None, drain: None,
decompress: None, decompress: None,
should_decompress: self.req.response_decompress(), should_decompress: self.req.response_decompress(),
@ -217,6 +218,7 @@ impl Future for SendRequest {
pub(crate) struct Pipeline { pub(crate) struct Pipeline {
body: IoBody, body: IoBody,
body_completed: bool,
conn: Option<Connection>, conn: Option<Connection>,
writer: HttpClientWriter, writer: HttpClientWriter,
parser: Option<HttpResponseParser>, parser: Option<HttpResponseParser>,
@ -394,7 +396,7 @@ impl Pipeline {
IoBody::Payload(mut body) => match body.poll()? { IoBody::Payload(mut body) => match body.poll()? {
Async::Ready(None) => { Async::Ready(None) => {
self.writer.write_eof()?; self.writer.write_eof()?;
self.disconnected = true; self.body_completed = true;
break; break;
} }
Async::Ready(Some(chunk)) => { Async::Ready(Some(chunk)) => {
@ -421,8 +423,7 @@ impl Pipeline {
for frame in vec { for frame in vec {
match frame { match frame {
Frame::Chunk(None) => { Frame::Chunk(None) => {
// info.context = Some(ctx); self.body_completed = true;
self.disconnected = true;
self.writer.write_eof()?; self.writer.write_eof()?;
break 'outter; break 'outter;
} }
@ -451,7 +452,7 @@ impl Pipeline {
} }
} }
IoBody::Done => { IoBody::Done => {
self.disconnected = true; self.body_completed = true;
done = true; done = true;
break; break;
} }
@ -472,7 +473,9 @@ impl Pipeline {
.poll_completed(self.conn.as_mut().unwrap(), false) .poll_completed(self.conn.as_mut().unwrap(), false)
{ {
Ok(Async::Ready(_)) => { Ok(Async::Ready(_)) => {
if self.disconnected { if self.disconnected
|| (self.body_completed && self.writer.is_completed())
{
self.write_state = RunningState::Done; self.write_state = RunningState::Done;
} else { } else {
self.write_state.resume(); self.write_state.resume();

View File

@ -61,6 +61,10 @@ impl HttpClientWriter {
self.buffer.take(); self.buffer.take();
} }
pub fn is_completed(&mut self) -> bool {
self.buffer.is_empty()
}
// pub fn keepalive(&self) -> bool { // pub fn keepalive(&self) -> bool {
// self.flags.contains(Flags::KEEPALIVE) && // self.flags.contains(Flags::KEEPALIVE) &&
// !self.flags.contains(Flags::UPGRADE) } // !self.flags.contains(Flags::UPGRADE) }