From d3f8f7c854887189d6b1a4b8d2501eb0f6c0515a Mon Sep 17 00:00:00 2001 From: Simon Hornby Date: Tue, 5 Aug 2025 12:22:29 +0200 Subject: [PATCH] fix: force feed eof when there's a hanging body --- actix-http/src/h1/dispatcher.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 00b51360e..88f3bb361 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -20,18 +20,18 @@ use tokio_util::codec::{Decoder as _, Encoder as _}; use tracing::{error, trace}; use super::{ + Message, MessageType, codec::Codec, decoder::MAX_BUFFER_SIZE, payload::{Payload, PayloadSender, PayloadStatus}, timer::TimerState, - Message, MessageType, }; use crate::{ + Error, Extensions, OnConnectData, Request, Response, StatusCode, body::{BodySize, BoxBody, MessageBody}, config::ServiceConfig, error::{DispatchError, ParseError, PayloadError}, service::HttpFlow, - Error, Extensions, OnConnectData, Request, Response, StatusCode, }; const LW_BUFFER_SIZE: usize = 1024; @@ -236,16 +236,12 @@ enum PollResponse { impl Dispatcher where T: AsyncRead + AsyncWrite + Unpin, - S: Service, S::Error: Into>, S::Response: Into>, - B: MessageBody, - X: Service, X::Error: Into>, - U: Service<(Request, Framed), Response = ()>, U::Error: fmt::Display, { @@ -291,16 +287,12 @@ where impl InnerDispatcher where T: AsyncRead + AsyncWrite + Unpin, - S: Service, S::Error: Into>, S::Response: Into>, - B: MessageBody, - X: Service, X::Error: Into>, - U: Service<(Request, Framed), Response = ()>, U::Error: fmt::Display, { @@ -654,6 +646,10 @@ where // to notify the dispatcher a new state is set and the outer loop // should be continue. Poll::Ready(Ok(res)) => { + let this = self.as_mut().project(); + if let Some(mut payload) = this.payload.take() { + payload.feed_eof(); + } let (res, body) = res.into().replace_body(()); self.as_mut().send_response(res, body) } @@ -1036,16 +1032,12 @@ where impl Future for Dispatcher where T: AsyncRead + AsyncWrite + Unpin, - S: Service, S::Error: Into>, S::Response: Into>, - B: MessageBody, - X: Service, X::Error: Into>, - U: Service<(Request, Framed), Response = ()>, U::Error: fmt::Display, {