testing, debugging, making things private
This commit is contained in:
@@ -112,15 +112,6 @@ impl<T> Frame<T> {
|
||||
&Reset(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_reset(&self) -> bool {
|
||||
use self::Frame::*;
|
||||
|
||||
match self {
|
||||
&Reset(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Errors that can occur during parsing an HTTP/2 frame.
|
||||
|
||||
@@ -27,9 +27,9 @@ extern crate log;
|
||||
|
||||
pub mod client;
|
||||
pub mod error;
|
||||
pub mod hpack;
|
||||
pub mod proto;
|
||||
pub mod frame;
|
||||
mod hpack;
|
||||
mod proto;
|
||||
mod frame;
|
||||
pub mod server;
|
||||
|
||||
mod util;
|
||||
|
||||
@@ -39,6 +39,8 @@ impl<T> FramedRead<T> {
|
||||
}
|
||||
|
||||
fn decode_frame(&mut self, mut bytes: Bytes) -> Result<Option<Frame>, ConnectionError> {
|
||||
trace!("decoding frame from {}B", bytes.len());
|
||||
|
||||
// Parse the head
|
||||
let head = frame::Head::parse(&bytes);
|
||||
|
||||
@@ -47,7 +49,7 @@ impl<T> FramedRead<T> {
|
||||
}
|
||||
|
||||
let kind = head.kind();
|
||||
debug!("received {:?}", kind);
|
||||
debug!("decoded; kind={:?}", kind);
|
||||
|
||||
let frame = match kind {
|
||||
Kind::Settings => {
|
||||
@@ -121,11 +123,13 @@ impl<T> Stream for FramedRead<T>
|
||||
|
||||
fn poll(&mut self) -> Poll<Option<Frame>, ConnectionError> {
|
||||
loop {
|
||||
trace!("poll");
|
||||
let bytes = match try_ready!(self.inner.poll()) {
|
||||
Some(bytes) => bytes.freeze(),
|
||||
None => return Ok(Async::Ready(None)),
|
||||
};
|
||||
|
||||
trace!("poll; bytes={}B", bytes.len());
|
||||
if let Some(frame) = try!(self.decode_frame(bytes)) {
|
||||
debug!("poll; frame={:?}", frame);
|
||||
return Ok(Async::Ready(Some(frame)));
|
||||
|
||||
@@ -110,29 +110,19 @@ impl<T, U> Stream for StreamRecvOpen<T>
|
||||
|
||||
trace!("poll");
|
||||
loop {
|
||||
let frame = match self.inner.poll()? {
|
||||
Async::NotReady => {
|
||||
panic!("poll: NotReady");
|
||||
}
|
||||
Async::Ready(None) => {
|
||||
panic!("poll: None");
|
||||
}
|
||||
Async::Ready(Some(f)) => {
|
||||
trace!("poll: id={:?} eos={}", f.stream_id(), f.is_end_stream());
|
||||
f
|
||||
}
|
||||
let frame = match try_ready!(self.inner.poll()) {
|
||||
None => return Ok(Async::Ready(None)),
|
||||
Some(f) => f,
|
||||
};
|
||||
// let frame = match try_ready!(self.inner.poll()) {
|
||||
// None => return Ok(Async::Ready(None)),
|
||||
// Some(f) => f,
|
||||
// };
|
||||
|
||||
let id = frame.stream_id();
|
||||
trace!("poll: id={:?}", id);
|
||||
|
||||
if id.is_zero() {
|
||||
if !frame.is_connection_frame() {
|
||||
return Err(ProtocolError.into())
|
||||
}
|
||||
|
||||
// Nothing to do on connection frames.
|
||||
return Ok(Async::Ready(Some(frame)));
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ impl<T, U> Sink for StreamSendOpen<T>
|
||||
if !frame.is_connection_frame() {
|
||||
return Err(InvalidStreamId.into())
|
||||
}
|
||||
|
||||
// Nothing to do on connection frames.
|
||||
return self.inner.start_send(frame);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
extern crate bytes;
|
||||
extern crate h2;
|
||||
extern crate http;
|
||||
extern crate futures;
|
||||
extern crate mock_io;
|
||||
extern crate env_logger;
|
||||
extern crate bytes;
|
||||
extern crate futures;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate mock_io;
|
||||
|
||||
// scoped so `cargo test client_request` dtrt.
|
||||
mod client_request {
|
||||
@@ -48,6 +50,7 @@ mod client_request {
|
||||
|
||||
let h2 = client::handshake(mock)
|
||||
.wait().unwrap();
|
||||
trace!("hands have been shook");
|
||||
|
||||
// At this point, the connection should be closed
|
||||
assert!(Stream::wait(h2).next().is_none());
|
||||
|
||||
Reference in New Issue
Block a user