From 13e60c226a6cbe695807722cb4446437c221fe16 Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Sat, 22 Sep 2018 05:30:41 +0200 Subject: [PATCH] Update reqwest to 0.9 (#16) --- Cargo.toml | 2 +- src/lib.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a12e99e..b5816bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ version = "0.10.1" url = "1" [dependencies.reqwest] -version = "0.8" +version = "0.9" optional = true [dependencies.clippy] diff --git a/src/lib.rs b/src/lib.rs index d466579..1af06f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,14 +47,14 @@ use url::Url; #[cfg(feature = "http")] use reqwest::Client; #[cfg(feature = "http")] -use reqwest::header::UserAgent; +use reqwest::header::USER_AGENT; #[cfg(feature = "http")] use reqwest::StatusCode; #[cfg(feature = "http")] use reqwest::Response; #[cfg(feature = "http")] -const USER_AGENT: &str = "robotparser-rs (https://crates.io/crates/robotparser)"; +const RP_USER_AGENT: &str = "robotparser-rs (https://crates.io/crates/robotparser)"; /// A rule line is a single "Allow:" (allowance==True) or "Disallow:" /// (allowance==False) followed by a path.""" @@ -255,8 +255,8 @@ impl<'a> RobotFileParser<'a> { /// Reads the robots.txt URL and feeds it to the parser. pub fn read(&self) { let client = Client::new(); - let mut request = client.get(self.url.clone()); - let request = request.header(UserAgent::new(USER_AGENT.to_owned())); + let request = client.get(self.url.clone()); + let request = request.header(USER_AGENT, RP_USER_AGENT.to_owned()); let mut res = match request.send() { Ok(res) => res, Err(_) => { @@ -265,13 +265,13 @@ impl<'a> RobotFileParser<'a> { }; let status = res.status(); match status { - StatusCode::Unauthorized | StatusCode::Forbidden => { + StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => { self.disallow_all.set(true); } - status if status >= StatusCode::BadRequest && status < StatusCode::InternalServerError => { + status if status >= StatusCode::BAD_REQUEST && status < StatusCode::INTERNAL_SERVER_ERROR => { self.allow_all.set(true); } - StatusCode::Ok => self.from_response(&mut res), + StatusCode::OK => self.from_response(&mut res), _ => {} } }