From dbcb99ecf2f30c95241805f345fc6e8671c14c73 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. --- lib/src/data/data_stream.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/data/data_stream.rs b/lib/src/data/data_stream.rs index fac1509d..c07d9406 100644 --- a/lib/src/data/data_stream.rs +++ b/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); } }