mirror of https://github.com/fafhrd91/actix-web
Drop connection without error on early read termination #2764
This commit is contained in:
parent
30004d5b9f
commit
a9e89b0db9
|
@ -22,7 +22,7 @@ use crate::{
|
||||||
config::ServiceConfig,
|
config::ServiceConfig,
|
||||||
error::{DispatchError, ParseError, PayloadError},
|
error::{DispatchError, ParseError, PayloadError},
|
||||||
service::HttpFlow,
|
service::HttpFlow,
|
||||||
ConnectionType, Error, Extensions, OnConnectData, Request, Response, StatusCode,
|
Error, Extensions, OnConnectData, Request, Response, StatusCode,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -727,7 +727,7 @@ where
|
||||||
this.state.set(State::None);
|
this.state.set(State::None);
|
||||||
|
|
||||||
// break out of payload decode loop
|
// break out of payload decode loop
|
||||||
break;
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either whole payload is read and loop is broken or more data
|
// Either whole payload is read and loop is broken or more data
|
||||||
|
@ -739,18 +739,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// not enough info to decide if connection is going to be clean or not
|
// no bytes in the read buffer, but there are still bytes to be read
|
||||||
|
// according to the content-length header. The client has stopped
|
||||||
|
// sending data early. Reset the state, set disconnection flag,
|
||||||
|
// and stop reading.
|
||||||
None => {
|
None => {
|
||||||
error!(
|
debug!("client stopped sending data; disconnecting");
|
||||||
"handler did not read whole payload and dispatcher could not \
|
// reset dispatcher state
|
||||||
drain read buf; return 500 and close connection"
|
|
||||||
);
|
|
||||||
|
|
||||||
this.flags.insert(Flags::SHUTDOWN);
|
this.flags.insert(Flags::SHUTDOWN);
|
||||||
let mut res = Response::internal_server_error().drop_body();
|
let _ = this.payload.take();
|
||||||
res.head_mut().set_connection_type(ConnectionType::Close);
|
this.state.set(State::None);
|
||||||
this.messages.push_back(DispatcherMessage::Error(res));
|
|
||||||
*this.error = Some(DispatchError::HandlerDroppedPayload);
|
// break out of payload decode loop
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue