diff --git a/src/error.rs b/src/error.rs index fe267770..c62f23c2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -191,8 +191,8 @@ impl Error { Error::new(Kind::Body, Some(cause.into())) } - pub(crate) fn new_body_write(cause: io::Error) -> Error { - Error::new(Kind::BodyWrite, Some(Box::new(cause))) + pub(crate) fn new_body_write>(cause: E) -> Error { + Error::new(Kind::BodyWrite, Some(cause.into())) } pub(crate) fn new_user_unsupported_version() -> Error { diff --git a/src/proto/h2/client.rs b/src/proto/h2/client.rs index deca0af8..c02175ad 100644 --- a/src/proto/h2/client.rs +++ b/src/proto/h2/client.rs @@ -64,7 +64,8 @@ where // parked Connection. let (tx, rx) = oneshot::channel(); let fut = conn - .map_err(|e| debug!("client h2 connection error: {}", e)) + .inspect(|_| trace!("connection complete")) + .map_err(|e| debug!("connection error: {}", e)) .select2(rx) .then(|res| match res { Ok(Either::A(((), _))) | @@ -132,7 +133,7 @@ where Ok(Async::Ready(None)) | Err(_) => { - trace!("client tx dropped"); + trace!("client::dispatch::Sender dropped"); return Ok(Async::Ready(())); } } diff --git a/src/proto/h2/mod.rs b/src/proto/h2/mod.rs index 06aab6a1..f30ad732 100644 --- a/src/proto/h2/mod.rs +++ b/src/proto/h2/mod.rs @@ -71,14 +71,25 @@ where // - call self.body_tx.poll_capacity(), return if NotReady match self.stream.poll_data() { Ok(Async::Ready(Some(chunk))) => { - trace!("send body chunk: {}B", chunk.as_ref().len()); - self.body_tx.send_data(SendBuf(Some(Cursor::new(chunk))), false) - .map_err(::Error::new_h2)?; + let is_eos = self.stream.is_end_stream(); + trace!( + "send body chunk: {} bytes, eos={}", + chunk.as_ref().len(), + is_eos, + ); + + let buf = SendBuf(Some(Cursor::new(chunk))); + self.body_tx.send_data(buf, is_eos) + .map_err(::Error::new_body_write)?; + + if is_eos { + return Ok(Async::Ready(())) + } }, Ok(Async::Ready(None)) => { trace!("send body eos"); self.body_tx.send_data(SendBuf(None), true) - .map_err(::Error::new_h2)?; + .map_err(::Error::new_body_write)?; return Ok(Async::Ready(())); }, Ok(Async::NotReady) => return Ok(Async::NotReady),