Skip to content

Commit e3b9ca6

Browse files
authored
Merge pull request #11 from spk/use-request-http-client
Use request higher level Client crate for openssl updates
2 parents a94a5b3 + 9f5b4c2 commit e3b9ca6

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ version = "0.7.0"
1313
[dependencies]
1414
url = "1.2"
1515

16-
[dependencies.hyper]
17-
version = "0.9"
16+
[dependencies.reqwest]
17+
version = "0.1.0"
1818
optional = true
1919

2020
[dependencies.clippy]
@@ -23,5 +23,5 @@ version = "^0.*"
2323

2424
[features]
2525
default = ["http"]
26-
http = ["hyper"]
26+
http = ["reqwest"]
2727
unstable = []

src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
extern crate url;
3636
#[cfg(feature = "http")]
37-
extern crate hyper;
37+
extern crate reqwest;
3838

3939
#[cfg(feature = "http")]
4040
use std::io::Read;
@@ -45,13 +45,13 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
4545
use url::Url;
4646

4747
#[cfg(feature = "http")]
48-
use hyper::Client;
48+
use reqwest::Client;
4949
#[cfg(feature = "http")]
50-
use hyper::header::UserAgent;
50+
use reqwest::header::UserAgent;
5151
#[cfg(feature = "http")]
52-
use hyper::status::StatusCode;
52+
use reqwest::StatusCode;
5353
#[cfg(feature = "http")]
54-
use hyper::client::Response;
54+
use reqwest::Response;
5555

5656
#[cfg(feature = "http")]
5757
const USER_AGENT: &'static str = "robotparser-rs (https://crates.io/crates/robotparser)";
@@ -254,7 +254,7 @@ impl<'a> RobotFileParser<'a> {
254254
#[cfg(feature = "http")]
255255
/// Reads the robots.txt URL and feeds it to the parser.
256256
pub fn read(&self) {
257-
let client = Client::new();
257+
let client = Client::new().expect("client failed to construct");
258258
let request = client.get(self.url.clone())
259259
.header(UserAgent(USER_AGENT.to_owned()));
260260
let mut res = match request.send() {
@@ -263,7 +263,8 @@ impl<'a> RobotFileParser<'a> {
263263
return;
264264
}
265265
};
266-
match res.status {
266+
let status = res.status().clone();
267+
match status {
267268
StatusCode::Unauthorized | StatusCode::Forbidden => {
268269
self.disallow_all.set(true);
269270
}

0 commit comments

Comments
 (0)