From 3eca681cc2873be8eaa01788a8fc30c25ce02c39 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Wed, 27 Jan 2021 02:37:38 -0800 Subject: [PATCH] add comment for None variant output of MessageType::decode for Request --- actix-http/src/h1/decoder.rs | 19 +++++++++++-------- actix-http/src/h1/dispatcher.rs | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/actix-http/src/h1/decoder.rs b/actix-http/src/h1/decoder.rs index 5ac5d906d..1f6731f0f 100644 --- a/actix-http/src/h1/decoder.rs +++ b/actix-http/src/h1/decoder.rs @@ -208,8 +208,9 @@ impl MessageType for Request { trace!("MAX_BUFFER_SIZE unprocessed data reached, closing"); Err(ParseError::TooLarge) } else { + // Return None to notify more read are needed for parsing request Ok(None) - } + }; } } }; @@ -277,14 +278,16 @@ impl MessageType for ResponseHead { (len, version, status, res.headers.len()) } - httparse::Status::Partial => return { - if src.len() >= MAX_BUFFER_SIZE { - error!("MAX_BUFFER_SIZE unprocessed data reached, closing"); - Err(ParseError::TooLarge) - } else { - Ok(None) + httparse::Status::Partial => { + return { + if src.len() >= MAX_BUFFER_SIZE { + error!("MAX_BUFFER_SIZE unprocessed data reached, closing"); + Err(ParseError::TooLarge) + } else { + Ok(None) + } } - }, + } } }; diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index fbd4acc92..c1140cca5 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -609,6 +609,8 @@ where } } } + // decode is partial and buffer is not full yet. + // break and wait for more read. Ok(None) => break, Err(ParseError::Io(e)) => { self.as_mut().client_disconnected();