Rust: hyper -> reqwest for the indexer
Since Hyper doesn't provide a synchronous API anymore.
This commit is contained in:
parent
f0df5092c3
commit
2974ee929e
4 changed files with 988 additions and 40 deletions
1012
indexer/Cargo.lock
generated
1012
indexer/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -14,7 +14,7 @@ encoding = { git = "https://github.com/lifthrasiir/rust-encoding", features = ["
|
||||||
ring = "0.14.6"
|
ring = "0.14.6"
|
||||||
postgres = "0.15.2"
|
postgres = "0.15.2"
|
||||||
clap = "2.31.2"
|
clap = "2.31.2"
|
||||||
hyper = { version = "0.10.13", default-features = false } # TODO: Update?
|
reqwest = "0.9.17"
|
||||||
url = "1.7.0"
|
url = "1.7.0"
|
||||||
chrono = "0.4.0"
|
chrono = "0.4.0"
|
||||||
quick-xml = "0.14.0"
|
quick-xml = "0.14.0"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ extern crate libc;
|
||||||
extern crate ring;
|
extern crate ring;
|
||||||
extern crate encoding;
|
extern crate encoding;
|
||||||
extern crate postgres;
|
extern crate postgres;
|
||||||
extern crate hyper;
|
extern crate reqwest;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
extern crate quick_xml;
|
extern crate quick_xml;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use regex::bytes::Regex;
|
||||||
use ring::digest;
|
use ring::digest;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use url::percent_encoding::percent_decode;
|
use url::percent_encoding::percent_decode;
|
||||||
use hyper;
|
use reqwest;
|
||||||
|
|
||||||
|
|
||||||
const CACHE_PATH: &'static str = "/var/tmp/manned-indexer";
|
const CACHE_PATH: &'static str = "/var/tmp/manned-indexer";
|
||||||
|
|
@ -33,14 +33,14 @@ fn cache_fn(url: &Url) -> String {
|
||||||
|
|
||||||
|
|
||||||
fn fetch(url: &str) -> Result<Box<Read>> {
|
fn fetch(url: &str) -> Result<Box<Read>> {
|
||||||
let res = try!(hyper::Client::new()
|
let res = try!(reqwest::Client::new()
|
||||||
.get(url)
|
.get(url)
|
||||||
.header(hyper::header::UserAgent("Man page crawler (info@manned.org; https://manned.org/)".to_owned()))
|
.header("User-Agent", "Man page crawler (info@manned.org; https://manned.org/)")
|
||||||
.send()
|
.send()
|
||||||
.map_err(|e| Error::new(ErrorKind::Other, format!("Hyper: {}", e)))
|
.map_err(|e| Error::new(ErrorKind::Other, format!("Reqwest: {}", e)))
|
||||||
);
|
);
|
||||||
if !res.status.is_success() {
|
if !res.status().is_success() {
|
||||||
return Err(Error::new(ErrorKind::Other, format!("HTTP: {}", res.status) ));
|
return Err(Error::new(ErrorKind::Other, format!("HTTP: {}", res.status()) ));
|
||||||
}
|
}
|
||||||
Ok(Box::new(res) as Box<Read>)
|
Ok(Box::new(res) as Box<Read>)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue