Misc protocol fixes

* Verify contiuation frame stream ID
* Fix sending RST_STREAM in certain cases.
This commit is contained in:
Carl Lerche
2017-08-25 10:21:47 -07:00
parent 0c8a94aa11
commit 91aa1db2ff
6 changed files with 83 additions and 28 deletions

View File

@@ -241,16 +241,17 @@ impl State {
}
}
/// Indicates that the local side will not send more data to the local.
pub fn send_reset(&mut self, reason: Reason) -> Result<(), ConnectionError> {
/// Set the stream state to reset
pub fn set_reset(&mut self, reason: Reason) {
debug_assert!(!self.is_reset());
self.inner = Closed(Some(Cause::Proto(reason)));
}
/// Returns true if the stream is already reset.
pub fn is_reset(&self) -> bool {
match self.inner {
Idle => Err(ProtocolError.into()),
Closed(..) => Ok(()),
_ => {
trace!("send_reset: => Closed");
self.inner = Closed(Some(Cause::Proto(reason)));
Ok(())
}
Closed(Some(_)) => true,
_ => false,
}
}