From 6a22c54ba2c7c75ec45ddf01f094424f6c776e9f Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sat, 28 Nov 2020 22:34:32 -0800 Subject: [PATCH] Small cleanups. --- src/response.rs | 13 +------------ src/stream.rs | 4 ++-- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/response.rs b/src/response.rs index 8e032d9..441f6be 100644 --- a/src/response.rs +++ b/src/response.rs @@ -526,18 +526,7 @@ pub(crate) fn set_stream(resp: &mut Response, url: String, unit: Option, s fn read_next_line(reader: &mut impl BufRead) -> io::Result { let mut s = String::new(); - let result = reader.read_line(&mut s).map_err(|e| { - // On unix-y platforms set_read_timeout and set_write_timeout - // causes ErrorKind::WouldBlock instead of ErrorKind::TimedOut. - // Since the socket most definitely not set_nonblocking(true), - // we can safely normalize WouldBlock to TimedOut - if e.kind() == io::ErrorKind::WouldBlock { - io::Error::new(io::ErrorKind::TimedOut, "timed out reading headers") - } else { - e - } - }); - if result? == 0 { + if reader.read_line(&mut s)? == 0 { return Err(io::Error::new( io::ErrorKind::ConnectionAborted, "Unexpected EOF", diff --git a/src/stream.rs b/src/stream.rs index 717b590..98cea90 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -138,13 +138,13 @@ impl Stream { fn from_tcp_stream(t: TcpStream) -> Stream { Stream { - inner: BufReader::with_capacity(1000, Inner::Http(t)), + inner: BufReader::new(Inner::Http(t)), } } fn from_tls_stream(t: StreamOwned) -> Stream { Stream { - inner: BufReader::with_capacity(1000, Inner::Https(t)), + inner: BufReader::new(Inner::Https(t)), } }