diff --git a/pingora-core/src/protocols/http/v2/server.rs b/pingora-core/src/protocols/http/v2/server.rs index 6d6b393b..718ddded 100644 --- a/pingora-core/src/protocols/http/v2/server.rs +++ b/pingora-core/src/protocols/http/v2/server.rs @@ -387,13 +387,15 @@ impl HttpSession { /// Whether there is no more body to read pub fn is_body_done(&self) -> bool { - self.request_body_reader.is_end_stream() + // Check no body in request + // Also check we hit end of stream + self.is_body_empty() || self.request_body_reader.is_end_stream() } - /// Whether there is any body to read. + /// Whether there is any body to read. true means there no body in request. pub fn is_body_empty(&self) -> bool { self.body_read == 0 - && (self.is_body_done() + && (self.request_body_reader.is_end_stream() || self .request_header .headers diff --git a/pingora-proxy/src/proxy_h1.rs b/pingora-proxy/src/proxy_h1.rs index 544a74e6..e13d4c15 100644 --- a/pingora-proxy/src/proxy_h1.rs +++ b/pingora-proxy/src/proxy_h1.rs @@ -311,7 +311,9 @@ impl HttpProxy { }, _ = tx.reserve(), if downstream_state.is_reading() && send_permit.is_err() => { - debug!("waiting for permit {send_permit:?}"); + // If tx is closed, downstream already finish its job. + downstream_state.maybe_finished(tx.is_closed()); + debug!("waiting for permit {send_permit:?}, downstream closed {}", tx.is_closed()); /* No permit, wait on more capacity to avoid starving. * Otherwise this select only blocks on rx, which might send no data * before the entire body is uploaded.