diff --git a/examples/client.rs b/examples/client.rs index ce203e7..b0a78a9 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -36,7 +36,7 @@ pub fn main() { .uri("https://http2.akamai.com/") .body(()).unwrap(); - let stream = client.request(request, true); + let stream = client.request(request, true).unwrap(); client.join(stream.and_then(|response| { println!("GOT RESPONSE: {:?}", response); Ok(()) diff --git a/examples/server.rs b/examples/server.rs index 80767d4..a88a4be 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -35,8 +35,15 @@ pub fn main() { println!("H2 connection bound"); - conn.for_each(|(request, stream)| { + conn.for_each(|(request, mut stream)| { println!("GOT request: {:?}", request); + + let response = Response::builder() + .status(status::OK) + .body(()).unwrap(); + + stream.send_response(response, true).unwrap(); + Ok(()) }) diff --git a/src/proto/streams/recv.rs b/src/proto/streams/recv.rs index 3c4c623..81b1251 100644 --- a/src/proto/streams/recv.rs +++ b/src/proto/streams/recv.rs @@ -132,18 +132,17 @@ impl Recv where B: Buf { self.inc_num_streams(); } + // Push the frame onto the stream's recv buffer + stream.pending_recv.push_back(&mut self.buffer, frame.into()); + stream.notify_recv(); + // Only servers can receive a headers frame that initiates the stream. // This is verified in `Streams` before calling this function. if P::is_server() { self.pending_accept.push(stream); - Ok(()) - } else { - // Push the frame onto the recv buffer - stream.pending_recv.push_back(&mut self.buffer, frame.into()); - stream.notify_recv(); - - Ok(()) } + + Ok(()) } pub fn recv_eos(&mut self, stream: &mut Stream) diff --git a/src/server.rs b/src/server.rs index 92ffd37..f249c96 100644 --- a/src/server.rs +++ b/src/server.rs @@ -112,6 +112,7 @@ impl futures::Stream for Server } if let Some(inner) = self.connection.next_incoming() { + trace!("received incoming"); let (head, _) = inner.take_request()?.into_parts(); let body = Body { inner: inner.clone() };