Force close only the read end of connections.

Previously, when a request's body data exceeded the expected length,
Rocket would shutdown both ends of the corresponding connection. This PR
changes the behavior so that only the read end of the connection, on
Rocket's side, is shutdown. This allows a response to be sent in the
future while still preventing DoS attacks due to exuberant data.

Fixes #386.
This commit is contained in:
Ryan 2018-07-19 15:55:43 -07:00 committed by Sergio Benitez
parent f941b1310b
commit 995603666f
1 changed files with 1 additions and 1 deletions

View File

@ -40,7 +40,7 @@ pub fn kill_stream(stream: &mut BodyReader) {
Ok(FLUSH_LEN) | Err(_) => {
warn_!("Data left unread. Force closing network stream.");
let (_, network) = stream.get_mut().get_mut();
if let Err(e) = network.close(Shutdown::Both) {
if let Err(e) = network.close(Shutdown::Read) {
error_!("Failed to close network stream: {:?}", e);
}
}