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

@@ -1,4 +1,5 @@
use {frame, ConnectionError};
use error::User::InactiveStreamId;
use proto::*;
use super::*;
@@ -108,6 +109,23 @@ impl<B> Send<B> where B: Buf {
stream.state.send_close()
}
pub fn send_reset(&mut self, reason: Reason,
stream: &mut store::Ptr<B>,
task: &mut Option<Task>)
-> Result<(), ConnectionError>
{
if stream.state.is_closed() {
return Err(InactiveStreamId.into())
}
stream.state.send_reset(reason)?;
let frame = frame::Reset::new(stream.id, reason);
self.prioritize.queue_frame(frame.into(), stream, task);
Ok(())
}
pub fn send_data(&mut self,
frame: frame::Data<B>,
stream: &mut store::Ptr<B>,