implement h2::server::Stream::send_reset(Reason) and Body::is_empty() (#22)

This commit is contained in:
Oliver Gould
2017-08-23 12:48:00 -07:00
committed by Carl Lerche
parent e8f757457b
commit f839443ece
7 changed files with 87 additions and 3 deletions

View File

@@ -242,6 +242,19 @@ 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> {
match self.inner {
Idle => Err(ProtocolError.into()),
Closed(..) => Ok(()),
_ => {
trace!("send_reset: => Closed");
self.inner = Closed(Some(Cause::Proto(reason)));
Ok(())
}
}
}
/// Returns true if a stream with the current state counts against the
/// concurrency limit.
pub fn is_counted(&self) -> bool {