mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-02 19:04:53 +00:00
Use timeout instead of connect_timeout
This commit is contained in:
parent
c953528fb7
commit
16649a1d22
4 changed files with 11 additions and 9 deletions
|
|
@ -38,12 +38,11 @@ lychee can...
|
|||
- show colored output
|
||||
- filter based on status codes (https://github.com/tcort/markdown-link-check/issues/94)
|
||||
(e.g. `--accept 200,204`)
|
||||
- accept a connect timeout (`--connect-timeout`). Default is 20s. Set to 0 for no timeout.
|
||||
- accept a request timeout (`--timeout`) in seconds. Default is 20s. Set to 0 for no timeout.
|
||||
|
||||
SOON:
|
||||
|
||||
- automatically retry and backoff
|
||||
- set timeout for HTTP requests in seconds (`--timeout`). Default is 10s. Set to 0 for no timeout. https://docs.rs/reqwest/0.10.7/reqwest/struct.ClientBuilder.html#method.pool_idle_timeout
|
||||
- check relative (`base-url` to set project root)
|
||||
- show the progress interactively with progress bar and in-flight requests (`--progress`)
|
||||
- usable as a library (https://github.com/raviqqe/liche/issues/13)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ impl Checker {
|
|||
custom_headers: HeaderMap,
|
||||
method: RequestMethod,
|
||||
accepted: Option<HashSet<http::StatusCode>>,
|
||||
connect_timeout: Option<Duration>,
|
||||
timeout: Option<Duration>,
|
||||
verbose: bool,
|
||||
) -> Result<Self> {
|
||||
let mut headers = header::HeaderMap::new();
|
||||
|
|
@ -106,8 +106,8 @@ impl Checker {
|
|||
.danger_accept_invalid_certs(allow_insecure)
|
||||
.redirect(reqwest::redirect::Policy::limited(max_redirects));
|
||||
|
||||
let builder = match connect_timeout {
|
||||
Some(connect_timeout) => builder.connect_timeout(connect_timeout),
|
||||
let builder = match timeout {
|
||||
Some(timeout) => builder.timeout(timeout),
|
||||
None => builder,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ async fn run(opts: LycheeOptions) -> Result<i32> {
|
|||
Some(accept) => parse_statuscodes(accept)?,
|
||||
None => None,
|
||||
};
|
||||
let connect_timeout = parse_timeout(opts.connect_timeout)?;
|
||||
let timeout = parse_timeout(opts.timeout)?;
|
||||
|
||||
let checker = Checker::try_new(
|
||||
env::var("GITHUB_TOKEN")?,
|
||||
|
|
@ -79,7 +79,7 @@ async fn run(opts: LycheeOptions) -> Result<i32> {
|
|||
headers,
|
||||
opts.method.try_into()?,
|
||||
accepted,
|
||||
Some(connect_timeout),
|
||||
Some(timeout),
|
||||
opts.verbose,
|
||||
)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,11 @@ pub(crate) struct LycheeOptions {
|
|||
#[options(help = "Comma-separated list of accepted status codes for valid links")]
|
||||
pub accept: Option<String>,
|
||||
|
||||
#[options(help = "Website connection timeout", default = "20")]
|
||||
pub connect_timeout: String,
|
||||
#[options(
|
||||
help = "Website timeout from connect to response finished",
|
||||
default = "20"
|
||||
)]
|
||||
pub timeout: String,
|
||||
|
||||
#[options(help = "Request method", default = "get")]
|
||||
pub method: String,
|
||||
|
|
|
|||
Loading…
Reference in a new issue