Add GoAway support

This commit is contained in:
Carl Lerche
2017-08-10 14:19:46 -07:00
parent 1974780504
commit a61562f6b8
6 changed files with 36 additions and 9 deletions

View File

@@ -128,6 +128,12 @@ impl<T, P, B> Connection<T, P, B>
// TODO: ACK must be sent THEN settings applied.
}
Some(GoAway(frame)) => {
// TODO: handle the last_stream_id. Also, should this be
// handled as an error?
let e = ConnectionError::Proto(frame.reason());
return Ok(().into());
}
Some(Ping(frame)) => {
trace!("recv PING; frame={:?}", frame);
self.ping_pong.recv_ping(frame);

View File

@@ -64,7 +64,6 @@ impl<T> FramedRead<T> {
let _ = bytes.split_to(frame::HEADER_LEN);
frame::Data::load(head, bytes)?.into()
}
Kind::Headers => {
let mut buf = Cursor::new(bytes);
buf.set_position(frame::HEADER_LEN as u64);
@@ -80,16 +79,11 @@ impl<T> FramedRead<T> {
frame.into()
}
Kind::Reset => {
frame::Reset::load(head, &bytes[frame::HEADER_LEN..])?.into()
}
// TODO
Kind::GoAway => {
let _todo = try!(frame::GoAway::load(&bytes[frame::HEADER_LEN..]));
unimplemented!();
frame::GoAway::load(&bytes[frame::HEADER_LEN..])?.into()
}
Kind::PushPromise => {
frame::PushPromise::load(head, &bytes[frame::HEADER_LEN..])?.into()

View File

@@ -141,6 +141,10 @@ impl<T, B> Sink for FramedWrite<T, B>
v.encode(self.buf.get_mut());
trace!("encoded settings; rem={:?}", self.buf.remaining());
}
Frame::GoAway(v) => {
v.encode(self.buf.get_mut());
trace!("encoded go_away; rem={:?}", self.buf.remaining());
}
Frame::Ping(v) => {
v.encode(self.buf.get_mut());
trace!("encoded ping; rem={:?}", self.buf.remaining());