don't flush headers if no expect present

applied from #2309 diff
This commit is contained in:
Rob Ede 2022-03-07 23:51:49 +00:00
parent 8bed235e5f
commit d551c8adf9
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
1 changed files with 7 additions and 3 deletions

View File

@ -83,12 +83,12 @@ where
false
};
framed.send((head, body.size()).into()).await?;
let mut pin_framed = Pin::new(&mut framed);
// special handle for EXPECT request.
let (do_send, mut res_head) = if is_expect {
pin_framed.send((head, body.size()).into()).await?;
let head = poll_fn(|cx| pin_framed.as_mut().poll_next(cx))
.await
.ok_or(ConnectError::Disconnected)??;
@ -97,13 +97,17 @@ where
// and current head would be used as final response head.
(head.status == StatusCode::CONTINUE, Some(head))
} else {
pin_framed.feed((head, body.size()).into()).await?;
(true, None)
};
if do_send {
// send request body
match body.size() {
BodySize::None | BodySize::Sized(0) => {}
BodySize::None | BodySize::Sized(0) => {
poll_fn(|cx| pin_framed.as_mut().flush(cx)).await?;
}
_ => send_body(body, pin_framed.as_mut()).await?,
};