From 7d2e5c0ef82cc28d4a21f8f3b812e3b62cb27aab Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 17 Jun 2015 11:36:54 -0700 Subject: [PATCH] style(client): use status.is_redirection() --- src/client/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 27aa52e5..08227d70 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -66,7 +66,6 @@ use header::{Headers, Header, HeaderFormat}; use header::{ContentLength, Location}; use method::Method; use net::{NetworkConnector, NetworkStream, ContextVerifier}; -use status::StatusClass::Redirection; use {Url}; use Error; @@ -87,6 +86,8 @@ use http::h1::Http11Protocol; pub struct Client { protocol: Box, redirect_policy: RedirectPolicy, + #[cfg(feature = "timeouts")] + read_timeout: Option } impl Client { @@ -125,6 +126,12 @@ impl Client { self.redirect_policy = policy; } + /// Set the read timeout value for all requests. + #[cfg(feature = "timeouts")] + pub fn set_read_timeout(&mut self, dur: Option) { + self.read_timeout = dur; + } + /// Build a Get request. pub fn get(&self, url: U) -> RequestBuilder { self.request(Method::Get, url) @@ -245,7 +252,7 @@ impl<'a, U: IntoUrl> RequestBuilder<'a, U> { let mut streaming = try!(req.start()); body.take().map(|mut rdr| copy(&mut rdr, &mut streaming)); let res = try!(streaming.send()); - if res.status.class() != Redirection { + if !res.status.is_redirection() { return Ok(res) } debug!("redirect code {:?} for {}", res.status, url);