pub(crate) struct WebsiteChecker {
method: Method,
github_client: Option<Octocrab>,
plugin_request_chain: RequestChain,
max_retries: u64,
retry_wait_time: Duration,
accepted: HashSet<StatusCode>,
require_https: bool,
include_fragments: bool,
fragment_checker: FragmentChecker,
redirect_history: RedirectHistory,
host_pool: Arc<HostPool>,
}Fields§
§method: MethodRequest method used for making requests.
github_client: Option<Octocrab>GitHub client used for requests.
plugin_request_chain: RequestChainThe chain of plugins to be executed on each request.
max_retries: u64Maximum number of retries per request before returning an error.
retry_wait_time: DurationInitial wait time between retries of failed requests. This doubles after each failure.
accepted: HashSet<StatusCode>Set of accepted return codes / status codes.
Unmatched return codes/ status codes are deemed as errors.
require_https: boolRequires using HTTPS when it’s available.
This would treat unencrypted links as errors when HTTPS is available.
include_fragments: boolWhether to check the existence of fragments in the response HTML files.
Will be disabled if the request method is HEAD.
fragment_checker: FragmentCheckerUtility for performing fragment checks in HTML files.
redirect_history: RedirectHistoryKeep track of HTTP redirections for reporting
host_pool: Arc<HostPool>Optional host pool for per-host rate limiting.
When present, HTTP requests will be routed through this pool for
rate limiting. When None, requests go directly through reqwest_client.
Implementations§
Source§impl WebsiteChecker
impl WebsiteChecker
pub(crate) fn new( method: Method, retry_wait_time: Duration, redirect_history: RedirectHistory, max_retries: u64, accepted: HashSet<StatusCode>, github_client: Option<Octocrab>, require_https: bool, plugin_request_chain: RequestChain, include_fragments: bool, host_pool: Arc<HostPool>, ) -> Self
Sourcepub(crate) async fn retry_request(&self, request: Request) -> Status
pub(crate) async fn retry_request(&self, request: Request) -> Status
Retry requests up to max_retries times
with an exponential backoff.
Note that, in addition, there also is a host-specific backoff
when host-specific rate limiting or errors are detected.
Sourceasync fn check_default(&self, request: Request) -> Status
async fn check_default(&self, request: Request) -> Status
Check a URI using reqwest.
async fn check_html_fragment( &self, url: Url, status: Status, content: &str, file_type: FileType, ) -> Status
Sourcepub(crate) async fn check_website(
&self,
uri: &Uri,
credentials: Option<BasicAuthCredentials>,
) -> Result<Status, ErrorKind>
pub(crate) async fn check_website( &self, uri: &Uri, credentials: Option<BasicAuthCredentials>, ) -> Result<Status, ErrorKind>
Checks the given URI of a website.
§Errors
This returns an Err if
- The URI is invalid.
- The request failed.
- The response status code is not accepted.
- The URI cannot be converted to HTTPS.
Sourceasync fn handle_insecure_url(
&self,
uri: &Uri,
default_chain: &Chain<Request, Status>,
status: Status,
) -> Result<Status, ErrorKind>
async fn handle_insecure_url( &self, uri: &Uri, default_chain: &Chain<Request, Status>, status: Status, ) -> Result<Status, ErrorKind>
Mark HTTP URLs as insecure, if the user required HTTPS and the URL is available under HTTPS.
Sourceasync fn check_website_inner(
&self,
uri: &Uri,
default_chain: &RequestChain,
) -> Status
async fn check_website_inner( &self, uri: &Uri, default_chain: &RequestChain, ) -> Status
Checks the given URI of a website.
Unsupported schemes will be ignored
Note: we use inner to improve compile times by avoiding monomorphization
§Errors
This returns an Err if
- The URI is invalid.
- The request failed.
- The response status code is not accepted.
async fn handle_github(&self, status: Status, uri: &Uri) -> Status
Sourceasync fn check_github(&self, uri: GithubUri) -> Status
async fn check_github(&self, uri: GithubUri) -> Status
Check a uri hosted on GitHub via the GitHub API.
§Caveats
Files inside private repositories won’t get checked and instead would be reported as valid if the repository itself is reachable through the API.
A better approach would be to download the file through the API or clone the repo, but we chose the pragmatic approach.
Trait Implementations§
Source§impl Clone for WebsiteChecker
impl Clone for WebsiteChecker
Source§fn clone(&self) -> WebsiteChecker
fn clone(&self) -> WebsiteChecker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WebsiteChecker
impl Debug for WebsiteChecker
Auto Trait Implementations§
impl !Freeze for WebsiteChecker
impl !RefUnwindSafe for WebsiteChecker
impl Send for WebsiteChecker
impl Sync for WebsiteChecker
impl Unpin for WebsiteChecker
impl UnsafeUnpin for WebsiteChecker
impl !UnwindSafe for WebsiteChecker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more