From 995f6e44a94ab53375ae7368d076521194b89bfc Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Mon, 28 Sep 2020 09:14:26 -0700 Subject: [PATCH] Pass through io::Errors when reading headers. (#166) Previously any io::Error on reading a status line or response headers would be unconditionally mapping into BadStatus or BadHeader. I think it's better to pass through the actual io::Error. BadStatusRead is still kept, since it has special status when dealing with timed out connections, and BadStatus is still used when the status line is malformed. --- src/response.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/response.rs b/src/response.rs index 4efb520..54fae37 100644 --- a/src/response.rs +++ b/src/response.rs @@ -478,14 +478,14 @@ impl Response { // HTTP/1.1 200 OK\r\n let status_line = read_next_line(&mut reader).map_err(|e| match e.kind() { ErrorKind::ConnectionAborted => Error::BadStatusRead, - _ => Error::BadStatus, + _ => Error::Io(e), })?; let (index, status) = parse_status_line(status_line.as_str())?; let mut headers: Vec
= Vec::new(); loop { - let line = read_next_line(&mut reader).map_err(|_| Error::BadHeader)?; + let line = read_next_line(&mut reader)?; if line.is_empty() { break; }