Merge pull request #15 from Y2Z/increase-timeout
Increase request timeout to 10 seconds
This commit is contained in:
commit
54ae61b728
3 changed files with 14 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "monolith"
|
||||
version = "2.0.3"
|
||||
version = "2.0.4"
|
||||
authors = ["Sunshine <sunshine@uberspace.net>"]
|
||||
|
||||
[dependencies]
|
||||
|
|
13
src/http.rs
13
src/http.rs
|
@ -2,8 +2,10 @@ extern crate regex;
|
|||
extern crate reqwest;
|
||||
extern crate url;
|
||||
|
||||
use self::reqwest::header::CONTENT_TYPE;
|
||||
use self::regex::Regex;
|
||||
use self::reqwest::Client;
|
||||
use self::reqwest::header::CONTENT_TYPE;
|
||||
use std::time::Duration;
|
||||
use self::url::{Url, ParseError};
|
||||
use utils::data_to_dataurl;
|
||||
|
||||
|
@ -61,7 +63,14 @@ pub fn retrieve_asset(url: &str, as_dataurl: bool, as_mime: &str) -> Result<Stri
|
|||
if url_is_data(&url).unwrap() {
|
||||
Ok(url.to_string())
|
||||
} else {
|
||||
let mut response = reqwest::get(url)?;
|
||||
let client = Client::builder()
|
||||
.timeout(Duration::from_secs(10))
|
||||
.build()
|
||||
.unwrap();
|
||||
let mut response = client
|
||||
.get(url)
|
||||
.send()
|
||||
.unwrap();
|
||||
|
||||
if as_dataurl {
|
||||
// Convert response into a byte array
|
||||
|
|
|
@ -7,7 +7,7 @@ use monolith::html::{walk_and_embed_assets, html_to_dom, print_dom};
|
|||
|
||||
fn main() {
|
||||
let command = App::new("monolith")
|
||||
.version("2.0.3")
|
||||
.version("2.0.4")
|
||||
.author("Sunshine <sunshine@uberspace.net>")
|
||||
.about("CLI tool to save web pages as single HTML files")
|
||||
.arg(Arg::with_name("url")
|
||||
|
@ -31,5 +31,6 @@ fn main() {
|
|||
walk_and_embed_assets(&arg_target, &dom.document, opt_no_js, opt_no_img);
|
||||
|
||||
print_dom(&dom.document);
|
||||
println!(); // Ensure newline at end of output
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue