From 8ede3b42183fa7f550d6135c6c30d5b4d9ee0884 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 2 Oct 2016 13:17:15 +0800 Subject: [PATCH 1/2] Feature gate hyper --- Cargo.toml | 9 +++++++-- src/lib.rs | 12 +++++++++++- tests/lib.rs | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aa74d97..35116f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,12 +11,17 @@ repository = "https://github.com/messense/robotparser-rs" version = "0.6.0" [dependencies] -hyper = "0.9" -url = "1.1" +url = "1.2" + +[dependencies.hyper] +version = "0.9" +optional = true [dependencies.clippy] optional = true version = "^0.*" [features] +default = ["http"] +http = ["hyper"] unstable = [] diff --git a/src/lib.rs b/src/lib.rs index 88cc2a3..e923e4a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,7 @@ //! //! # Examples //! -//! ``` +//! ```ignore //! extern crate robotparser; //! //! use robotparser::RobotFileParser; @@ -33,19 +33,27 @@ #![cfg_attr(feature="clippy", warn(cyclomatic_complexity))] extern crate url; +#[cfg(feature = "http")] extern crate hyper; +#[cfg(feature = "http")] use std::io::Read; use std::cell::{Cell, RefCell}; use std::borrow::Cow; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use url::Url; + +#[cfg(feature = "http")] use hyper::Client; +#[cfg(feature = "http")] use hyper::header::UserAgent; +#[cfg(feature = "http")] use hyper::status::StatusCode; +#[cfg(feature = "http")] use hyper::client::Response; +#[cfg(feature = "http")] const USER_AGENT: &'static str = "robotparser-rs (https://crates.io/crates/robotparser)"; /// A rule line is a single "Allow:" (allowance==True) or "Disallow:" @@ -243,6 +251,7 @@ impl<'a> RobotFileParser<'a> { self.last_checked.set(0i64); } + #[cfg(feature = "http")] /// Reads the robots.txt URL and feeds it to the parser. pub fn read(&self) { let client = Client::new(); @@ -266,6 +275,7 @@ impl<'a> RobotFileParser<'a> { } } + #[cfg(feature = "http")] /// Reads the HTTP response and feeds it to the parser. pub fn from_response(&self, response: &mut Response) { let mut buf = String::new(); diff --git a/tests/lib.rs b/tests/lib.rs index ae9fff8..9a43848 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -213,6 +213,7 @@ fn test_robots_txt_13() { robot_test_simple(doc, good, bad); } +#[cfg(feature = "http")] #[test] fn test_robots_txt_read() { let parser = RobotFileParser::new("http://www.python.org/robots.txt"); From 66661fda1e5551cf3873c91f84033b0c5f7f2c54 Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 5 Oct 2016 10:50:22 +0800 Subject: [PATCH 2/2] Upgrade Win32 OpenSSL on Appveyor CI --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 82506ec..ce699cd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,8 +8,8 @@ environment: # - TARGET: x86_64-pc-windows-msvc # BITS: 64 install: - - ps: Start-FileDownload "http://slproweb.com/download/Win${env:BITS}OpenSSL-1_0_2h.exe" - - Win%BITS%OpenSSL-1_0_2h.exe /SILENT /VERYSILENT /SP- /DIR="C:\OpenSSL" + - ps: Start-FileDownload "http://slproweb.com/download/Win${env:BITS}OpenSSL-1_0_2j.exe" + - Win%BITS%OpenSSL-1_0_2j.exe /SILENT /VERYSILENT /SP- /DIR="C:\OpenSSL" - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin