Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use request higher level Client crate for openssl updates #11

Merged
merged 1 commit into from Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -13,8 +13,8 @@ version = "0.7.0"
[dependencies]
url = "1.2"

[dependencies.hyper]
version = "0.9"
[dependencies.reqwest]
version = "0.1.0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my mistake.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should bump our version to 0.8.0 actually.

optional = true

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

[features]
default = ["http"]
http = ["hyper"]
http = ["reqwest"]
unstable = []
15 changes: 8 additions & 7 deletions src/lib.rs
Expand Up @@ -34,7 +34,7 @@

extern crate url;
#[cfg(feature = "http")]
extern crate hyper;
extern crate reqwest;

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

#[cfg(feature = "http")]
use hyper::Client;
use reqwest::Client;
#[cfg(feature = "http")]
use hyper::header::UserAgent;
use reqwest::header::UserAgent;
#[cfg(feature = "http")]
use hyper::status::StatusCode;
use reqwest::StatusCode;
#[cfg(feature = "http")]
use hyper::client::Response;
use reqwest::Response;

#[cfg(feature = "http")]
const USER_AGENT: &'static str = "robotparser-rs (https://crates.io/crates/robotparser)";
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<'a> RobotFileParser<'a> {
#[cfg(feature = "http")]
/// Reads the robots.txt URL and feeds it to the parser.
pub fn read(&self) {
let client = Client::new();
let client = Client::new().expect("client failed to construct");
let request = client.get(self.url.clone())
.header(UserAgent(USER_AGENT.to_owned()));
let mut res = match request.send() {
Expand All @@ -263,7 +263,8 @@ impl<'a> RobotFileParser<'a> {
return;
}
};
match res.status {
let status = res.status().clone();
match status {
StatusCode::Unauthorized | StatusCode::Forbidden => {
self.disallow_all.set(true);
}
Expand Down