From 6005827c3e1f58ec1a35266cf46563b2922343da Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 24 Oct 2018 15:20:21 -0700 Subject: [PATCH] refactor(http2): set content-length even when full_data is available --- src/proto/h2/server.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/proto/h2/server.rs b/src/proto/h2/server.rs index 9af2073e..7714a1b8 100644 --- a/src/proto/h2/server.rs +++ b/src/proto/h2/server.rs @@ -226,6 +226,11 @@ where }) } + // automatically set Content-Length from body... + if let Some(len) = body.content_length() { + headers::set_content_length_if_missing(res.headers_mut(), len); + } + if let Some(full) = body.__hyper_full_data(FullDataArg(())).0 { let mut body_tx = reply!(false); let buf = SendBuf(Some(full)); @@ -235,10 +240,6 @@ where return Ok(Async::Ready(())); } - // automatically set Content-Length from body... - if let Some(len) = body.content_length() { - headers::set_content_length_if_missing(res.headers_mut(), len); - } if !body.is_end_stream() { let body_tx = reply!(false); H2StreamState::Body(PipeToSendStream::new(body, body_tx))