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.
This commit is contained in:
committed by
GitHub
parent
e4d2ce8494
commit
995f6e44a9
@@ -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<Header> = 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user