From 995603666f855dc9923508446e0abb611cd478f5 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 19 Jul 2018 15:55:43 -0700 Subject: [PATCH] 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. --- core/lib/src/data/data_stream.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/src/data/data_stream.rs b/core/lib/src/data/data_stream.rs index 367358a2..1aa20430 100644 --- a/core/lib/src/data/data_stream.rs +++ b/core/lib/src/data/data_stream.rs @@ -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); } }