Implement ping_pong (#1)

* comments

* wip

* wip

* Sketch out pingpong and keepalive stack modules

PingPong responds to ping requests with acknowledgements.
KeepAlive issues ping requests on idle connections.

* remove keepalive for now

* commentary

* prettify ping_pong's poll

* test ping pong and passthrough

* add buffering test

* Use a fixed-size slice for ping payloads

* Improve pong dispatch

pong messages should be buffered until Stream::poll returns
Async::NotReady or Async::Ready(None) (i.e. such that it is not expected
to be polled again).  pong messages are now dispatched when no more data
may be polled or the Sink half is activated.

* revert name change

* touchup

* wip

* Simplify Stream::poll

Now PingPong only holds at most one pending pong and the stream will not
produce additional frames unti the ping has been sent.

Furthermore, we shouldn't have to call inner.poll_complete quite so
frequently.

* avoid Bytes::split_to

* only use buf internally to Ping::load
This commit is contained in:
Oliver Gould
2017-06-30 13:58:14 -07:00
committed by Carl Lerche
parent a7b92d5ec2
commit 7f21954724
8 changed files with 334 additions and 11 deletions

View File

@@ -27,6 +27,7 @@ mod data;
mod go_away;
mod head;
mod headers;
mod ping;
mod reset;
mod settings;
mod util;
@@ -35,6 +36,7 @@ pub use self::data::Data;
pub use self::go_away::GoAway;
pub use self::head::{Head, Kind, StreamId};
pub use self::headers::{Headers, PushPromise, Continuation, Pseudo};
pub use self::ping::Ping;
pub use self::reset::Reset;
pub use self::settings::{Settings, SettingSet};
@@ -52,6 +54,7 @@ pub enum Frame {
Headers(Headers),
PushPromise(PushPromise),
Settings(Settings),
Ping(Ping)
}
/// Errors that can occur during parsing an HTTP/2 frame.
@@ -66,6 +69,9 @@ pub enum Error {
/// An unsupported value was set for the frame kind.
BadKind,
/// A length value other than 8 was set on a PING message.
BadFrameSize,
/// The padding length was larger than the frame-header-specified
/// length of the payload.
TooMuchPadding,
@@ -92,7 +98,7 @@ pub enum Error {
/// An invalid stream identifier was provided.
///
/// This is returned if a settings frame is received with a stream
/// This is returned if a SETTINGS or PING frame is received with a stream
/// identifier other than zero.
InvalidStreamId,