fix Body to return errors when there is recv error

This commit is contained in:
Sean McArthur
2017-09-11 14:46:46 -07:00
parent ed472f109c
commit e2cda1860b
3 changed files with 17 additions and 32 deletions

View File

@@ -565,16 +565,7 @@ where
// No more data frames // No more data frames
Ok(None.into()) Ok(None.into())
}, },
None => { None => self.schedule_recv(stream),
if stream.state.is_recv_closed() {
// No more data frames will be received
Ok(None.into())
} else {
// Request to get notified once more data frames arrive
stream.recv_task = Some(task::current());
Ok(Async::NotReady)
}
},
} }
} }
@@ -590,16 +581,18 @@ where
// we do? // we do?
unimplemented!(); unimplemented!();
}, },
None => { None => self.schedule_recv(stream),
if stream.state.is_recv_closed() { }
// There will be no trailer frame }
Ok(None.into())
} else { fn schedule_recv<T>(&mut self, stream: &mut Stream<B, P>) -> Poll<Option<T>, proto::Error> {
// Request to get notified once another frame arrives if stream.state.ensure_recv_open()? {
// Request to get notified once more frames arrive
stream.recv_task = Some(task::current()); stream.recv_task = Some(task::current());
Ok(Async::NotReady) Ok(Async::NotReady)
} } else {
}, // No more frames will be received
Ok(None.into())
} }
} }
} }

View File

@@ -314,14 +314,15 @@ impl State {
} }
} }
pub fn ensure_recv_open(&self) -> Result<(), proto::Error> { pub fn ensure_recv_open(&self) -> Result<bool, proto::Error> {
use std::io; use std::io;
// TODO: Is this correct? // TODO: Is this correct?
match self.inner { match self.inner {
Closed(Some(Cause::Proto(reason))) => Err(proto::Error::Proto(reason)), Closed(Some(Cause::Proto(reason))) => Err(proto::Error::Proto(reason)),
Closed(Some(Cause::Io)) => Err(proto::Error::Io(io::ErrorKind::BrokenPipe.into())), Closed(Some(Cause::Io)) => Err(proto::Error::Io(io::ErrorKind::BrokenPipe.into())),
_ => Ok(()), Closed(None) | HalfClosedRemote(..) => Ok(false),
_ => Ok(true),
} }
} }
} }

View File

@@ -225,17 +225,8 @@ fn recv_data_overflows_connection_window() {
.and_then(|resp| { .and_then(|resp| {
assert_eq!(resp.status(), StatusCode::OK); assert_eq!(resp.status(), StatusCode::OK);
let body = resp.into_parts().1; let body = resp.into_parts().1;
// FIXME: body stream should error also
body.concat2().unwrap() body.concat2().unwrap()
/* FIXME: body stream should error also
.then(|res| {
let err = res.unwrap_err();
assert_eq!(
err.to_string(),
"protocol error: flow-control protocol violated"
);
Ok::<(), ()>(())
})
*/
}); });
// client should see a flow control error // client should see a flow control error