mirror of https://github.com/fafhrd91/actix-web
fix: force feed eof when there's a hanging body
This commit is contained in:
parent
e3ae20de30
commit
d3f8f7c854
|
@ -20,18 +20,18 @@ use tokio_util::codec::{Decoder as _, Encoder as _};
|
||||||
use tracing::{error, trace};
|
use tracing::{error, trace};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
Message, MessageType,
|
||||||
codec::Codec,
|
codec::Codec,
|
||||||
decoder::MAX_BUFFER_SIZE,
|
decoder::MAX_BUFFER_SIZE,
|
||||||
payload::{Payload, PayloadSender, PayloadStatus},
|
payload::{Payload, PayloadSender, PayloadStatus},
|
||||||
timer::TimerState,
|
timer::TimerState,
|
||||||
Message, MessageType,
|
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Extensions, OnConnectData, Request, Response, StatusCode,
|
||||||
body::{BodySize, BoxBody, MessageBody},
|
body::{BodySize, BoxBody, MessageBody},
|
||||||
config::ServiceConfig,
|
config::ServiceConfig,
|
||||||
error::{DispatchError, ParseError, PayloadError},
|
error::{DispatchError, ParseError, PayloadError},
|
||||||
service::HttpFlow,
|
service::HttpFlow,
|
||||||
Error, Extensions, OnConnectData, Request, Response, StatusCode,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const LW_BUFFER_SIZE: usize = 1024;
|
const LW_BUFFER_SIZE: usize = 1024;
|
||||||
|
@ -236,16 +236,12 @@ enum PollResponse {
|
||||||
impl<T, S, B, X, U> Dispatcher<T, S, B, X, U>
|
impl<T, S, B, X, U> Dispatcher<T, S, B, X, U>
|
||||||
where
|
where
|
||||||
T: AsyncRead + AsyncWrite + Unpin,
|
T: AsyncRead + AsyncWrite + Unpin,
|
||||||
|
|
||||||
S: Service<Request>,
|
S: Service<Request>,
|
||||||
S::Error: Into<Response<BoxBody>>,
|
S::Error: Into<Response<BoxBody>>,
|
||||||
S::Response: Into<Response<B>>,
|
S::Response: Into<Response<B>>,
|
||||||
|
|
||||||
B: MessageBody,
|
B: MessageBody,
|
||||||
|
|
||||||
X: Service<Request, Response = Request>,
|
X: Service<Request, Response = Request>,
|
||||||
X::Error: Into<Response<BoxBody>>,
|
X::Error: Into<Response<BoxBody>>,
|
||||||
|
|
||||||
U: Service<(Request, Framed<T, Codec>), Response = ()>,
|
U: Service<(Request, Framed<T, Codec>), Response = ()>,
|
||||||
U::Error: fmt::Display,
|
U::Error: fmt::Display,
|
||||||
{
|
{
|
||||||
|
@ -291,16 +287,12 @@ where
|
||||||
impl<T, S, B, X, U> InnerDispatcher<T, S, B, X, U>
|
impl<T, S, B, X, U> InnerDispatcher<T, S, B, X, U>
|
||||||
where
|
where
|
||||||
T: AsyncRead + AsyncWrite + Unpin,
|
T: AsyncRead + AsyncWrite + Unpin,
|
||||||
|
|
||||||
S: Service<Request>,
|
S: Service<Request>,
|
||||||
S::Error: Into<Response<BoxBody>>,
|
S::Error: Into<Response<BoxBody>>,
|
||||||
S::Response: Into<Response<B>>,
|
S::Response: Into<Response<B>>,
|
||||||
|
|
||||||
B: MessageBody,
|
B: MessageBody,
|
||||||
|
|
||||||
X: Service<Request, Response = Request>,
|
X: Service<Request, Response = Request>,
|
||||||
X::Error: Into<Response<BoxBody>>,
|
X::Error: Into<Response<BoxBody>>,
|
||||||
|
|
||||||
U: Service<(Request, Framed<T, Codec>), Response = ()>,
|
U: Service<(Request, Framed<T, Codec>), Response = ()>,
|
||||||
U::Error: fmt::Display,
|
U::Error: fmt::Display,
|
||||||
{
|
{
|
||||||
|
@ -654,6 +646,10 @@ where
|
||||||
// to notify the dispatcher a new state is set and the outer loop
|
// to notify the dispatcher a new state is set and the outer loop
|
||||||
// should be continue.
|
// should be continue.
|
||||||
Poll::Ready(Ok(res)) => {
|
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(());
|
let (res, body) = res.into().replace_body(());
|
||||||
self.as_mut().send_response(res, body)
|
self.as_mut().send_response(res, body)
|
||||||
}
|
}
|
||||||
|
@ -1036,16 +1032,12 @@ where
|
||||||
impl<T, S, B, X, U> Future for Dispatcher<T, S, B, X, U>
|
impl<T, S, B, X, U> Future for Dispatcher<T, S, B, X, U>
|
||||||
where
|
where
|
||||||
T: AsyncRead + AsyncWrite + Unpin,
|
T: AsyncRead + AsyncWrite + Unpin,
|
||||||
|
|
||||||
S: Service<Request>,
|
S: Service<Request>,
|
||||||
S::Error: Into<Response<BoxBody>>,
|
S::Error: Into<Response<BoxBody>>,
|
||||||
S::Response: Into<Response<B>>,
|
S::Response: Into<Response<B>>,
|
||||||
|
|
||||||
B: MessageBody,
|
B: MessageBody,
|
||||||
|
|
||||||
X: Service<Request, Response = Request>,
|
X: Service<Request, Response = Request>,
|
||||||
X::Error: Into<Response<BoxBody>>,
|
X::Error: Into<Response<BoxBody>>,
|
||||||
|
|
||||||
U: Service<(Request, Framed<T, Codec>), Response = ()>,
|
U: Service<(Request, Framed<T, Codec>), Response = ()>,
|
||||||
U::Error: fmt::Display,
|
U::Error: fmt::Display,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue