Introduce Frame::close_stream ctor

This commit is contained in:
Thomas Eizinger
2022-10-20 14:44:17 +11:00
parent 7dcecdeda9
commit fe7d00056b
2 changed files with 12 additions and 7 deletions

View File

@@ -630,13 +630,8 @@ impl<T: AsyncRead + AsyncWrite + Unpin> Active<T> {
fn on_close_stream(&mut self, id: StreamId, ack: bool) {
log::trace!("{}/{}: sending close", self.id, id);
let mut header = Header::data(id, 0);
header.fin();
if ack {
header.ack()
}
let frame = Frame::new(header);
self.pending_frames.push_back(frame.into());
self.pending_frames
.push_back(Frame::close_stream(id, ack).into());
}
/// Process the result of reading from the socket.

View File

@@ -98,6 +98,16 @@ impl Frame<Data> {
})
}
pub fn close_stream(id: StreamId, ack: bool) -> Self {
let mut header = Header::data(id, 0);
header.fin();
if ack {
header.ack()
}
Frame::new(header)
}
pub fn body(&self) -> &[u8] {
&self.body
}