Compare commits

...

4 Commits

Author SHA1 Message Date
Simon Hornby d5512e9739
Merge 9b68186946 into 8996198f2c 2025-08-27 10:24:17 +09:00
Simon Hornby 9b68186946 chore: reduce down to minimal fix 2025-08-22 19:13:50 +09:00
Simon Hornby a816f617d1 fix: finalize hanging payloads 2025-08-22 19:13:50 +09:00
Simon Hornby d3f8f7c854 fix: force feed eof when there's a hanging body 2025-08-22 19:13:50 +09:00
1 changed files with 13 additions and 0 deletions

View File

@ -304,6 +304,14 @@ where
U: Service<(Request, Framed<T, Codec>), Response = ()>,
U::Error: fmt::Display,
{
fn finalize_payload_if_present(mut self: Pin<&mut Self>, reason: &str) {
let this = self.as_mut().project();
if let Some(mut payload) = this.payload.take() {
trace!("Finalizing payload early: {reason}");
payload.feed_eof();
}
}
fn can_read(&self, cx: &mut Context<'_>) -> bool {
if self.flags.contains(Flags::READ_DISCONNECT) {
false
@ -686,6 +694,11 @@ where
// limit amount of non-processed requests
if pipeline_queue_full || can_not_read {
// since we're here, it's possible the client has been sent a response before we've been able to read the body
// in this case, we should eof the payload to prevent the next request from reading invalid data
// this can occur with certain load balancers that pipeline requests
self.as_mut()
.finalize_payload_if_present("pipeline queue full or cannot read");
return Ok(false);
}