1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 09:42:40 +01:00

Add some comments to clarify logic.

This commit is contained in:
Robert G. Jakabosky 2018-09-01 02:15:36 +08:00
parent 2341656173
commit a42a8a2321

View File

@ -39,6 +39,7 @@ impl HttpResponseParser {
T: IoStream, T: IoStream,
{ {
loop { loop {
// Read some more data into the buffer for the parser.
match io.read_available(buf) { match io.read_available(buf) {
Ok(Async::Ready((false, true))) => { Ok(Async::Ready((false, true))) => {
return Err(HttpResponseParserError::Disconnect) return Err(HttpResponseParserError::Disconnect)
@ -49,6 +50,8 @@ impl HttpResponseParser {
return Err(HttpResponseParserError::Error(err.into())) return Err(HttpResponseParserError::Error(err.into()))
} }
} }
// Call HTTP response parser.
match HttpResponseParser::parse_message(buf) match HttpResponseParser::parse_message(buf)
.map_err(HttpResponseParserError::Error)? .map_err(HttpResponseParserError::Error)?
{ {
@ -60,6 +63,7 @@ impl HttpResponseParser {
if buf.capacity() >= MAX_BUFFER_SIZE { if buf.capacity() >= MAX_BUFFER_SIZE {
return Err(HttpResponseParserError::Error(ParseError::TooLarge)); return Err(HttpResponseParserError::Error(ParseError::TooLarge));
} }
// Parser needs more data. Loop and read more data.
} }
} }
} }