Merge pull request #15 from Y2Z/increase-timeout

Increase request timeout to 10 seconds
This commit is contained in:
Vincent Flyson 2019-08-23 05:23:12 -04:00 committed by GitHub
commit 54ae61b728
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "monolith"
version = "2.0.3"
version = "2.0.4"
authors = ["Sunshine <sunshine@uberspace.net>"]
[dependencies]

View file

@ -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

View file

@ -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
}
}