add SendResponse::poll_reset and SendStream::poll_reset to listen for reset streams (#279)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
use std::io;
|
||||
|
||||
use codec::{RecvError, UserError};
|
||||
use codec::UserError::*;
|
||||
use frame::Reason;
|
||||
use proto;
|
||||
use proto::{self, PollReset};
|
||||
|
||||
use self::Inner::*;
|
||||
use self::Peer::*;
|
||||
@@ -399,8 +401,6 @@ impl State {
|
||||
}
|
||||
|
||||
pub fn ensure_recv_open(&self) -> Result<bool, proto::Error> {
|
||||
use std::io;
|
||||
|
||||
// TODO: Is this correct?
|
||||
match self.inner {
|
||||
Closed(Cause::Proto(reason)) |
|
||||
@@ -412,6 +412,24 @@ impl State {
|
||||
_ => Ok(true),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a reason if the stream has been reset.
|
||||
pub(super) fn ensure_reason(&self, mode: PollReset) -> Result<Option<Reason>, ::Error> {
|
||||
match self.inner {
|
||||
Closed(Cause::Proto(reason)) |
|
||||
Closed(Cause::LocallyReset(reason)) |
|
||||
Closed(Cause::Scheduled(reason)) => Ok(Some(reason)),
|
||||
Closed(Cause::Io) => Err(proto::Error::Io(io::ErrorKind::BrokenPipe.into()).into()),
|
||||
Open { local: Streaming, .. } |
|
||||
HalfClosedRemote(Streaming) => match mode {
|
||||
PollReset::AwaitingHeaders => {
|
||||
Err(UserError::PollResetAfterSendResponse.into())
|
||||
},
|
||||
PollReset::Streaming => Ok(None),
|
||||
},
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for State {
|
||||
|
||||
Reference in New Issue
Block a user