@@ -278,7 +278,7 @@ pub struct ClientBuilder {
278
278
/// Requests run through this chain where each item in the chain
279
279
/// can modify the request. A chained item can also decide to exit
280
280
/// early and return a status, so that subsequent chain items are
281
- /// skipped and no HTTP request is ever made .
281
+ /// skipped and the lychee-internal request chain is not activated .
282
282
plugin_request_chain : RequestChain ,
283
283
}
284
284
@@ -486,7 +486,7 @@ impl Client {
486
486
return Ok ( Response :: new ( uri. clone ( ) , Status :: Excluded , source) ) ;
487
487
}
488
488
489
- let request_chain : RequestChain = Chain :: new ( vec ! [
489
+ let chain : RequestChain = Chain :: new ( vec ! [
490
490
Box :: <Quirks >:: default ( ) ,
491
491
Box :: new( credentials) ,
492
492
Box :: new( Checker :: new(
@@ -500,7 +500,7 @@ impl Client {
500
500
let status = match uri. scheme ( ) {
501
501
_ if uri. is_file ( ) => self . check_file ( uri) . await ,
502
502
_ if uri. is_mail ( ) => self . check_mail ( uri) . await ,
503
- _ => self . check_website ( uri, request_chain ) . await ?,
503
+ _ => self . check_website ( uri, chain ) . await ?,
504
504
} ;
505
505
506
506
Ok ( Response :: new ( uri. clone ( ) , status, source) )
@@ -533,11 +533,11 @@ impl Client {
533
533
/// - The request failed.
534
534
/// - The response status code is not accepted.
535
535
/// - The URI cannot be converted to HTTPS.
536
- pub async fn check_website ( & self , uri : & Uri , request_chain : RequestChain ) -> Result < Status > {
537
- match self . check_website_inner ( uri, & request_chain ) . await {
536
+ pub async fn check_website ( & self , uri : & Uri , chain : RequestChain ) -> Result < Status > {
537
+ match self . check_website_inner ( uri, & chain ) . await {
538
538
Status :: Ok ( code) if self . require_https && uri. scheme ( ) == "http" => {
539
539
if self
540
- . check_website_inner ( & uri. to_https ( ) ?, & request_chain )
540
+ . check_website_inner ( & uri. to_https ( ) ?, & chain )
541
541
. await
542
542
. is_success ( )
543
543
{
@@ -562,7 +562,7 @@ impl Client {
562
562
/// - The URI is invalid.
563
563
/// - The request failed.
564
564
/// - The response status code is not accepted.
565
- pub async fn check_website_inner ( & self , uri : & Uri , request_chain : & RequestChain ) -> Status {
565
+ pub async fn check_website_inner ( & self , uri : & Uri , chain : & RequestChain ) -> Status {
566
566
// Workaround for upstream reqwest panic
567
567
if validate_url ( & uri. url ) {
568
568
if matches ! ( uri. scheme( ) , "http" | "https" ) {
@@ -587,16 +587,21 @@ impl Client {
587
587
Err ( e) => return e. into ( ) ,
588
588
} ;
589
589
590
- let chain = ClientRequestChain :: new ( vec ! [ & self . plugin_request_chain, request_chain] ) ;
591
- let status = chain. traverse ( request) . await ;
590
+ let status = ClientRequestChain :: new ( vec ! [ & self . plugin_request_chain, chain] )
591
+ . traverse ( request)
592
+ . await ;
593
+
594
+ self . handle_github ( status, uri) . await
595
+ }
592
596
597
+ // Pull out the heavy machinery in case of a failed normal request.
598
+ // This could be a GitHub URL and we ran into the rate limiter.
599
+ // TODO: We should first try to parse the URI as GitHub URI first (Lucius, Jan 2023)
600
+ async fn handle_github ( & self , status : Status , uri : & Uri ) -> Status {
593
601
if status. is_success ( ) {
594
602
return status;
595
603
}
596
604
597
- // Pull out the heavy machinery in case of a failed normal request.
598
- // This could be a GitHub URL and we ran into the rate limiter.
599
- // TODO: We should first try to parse the URI as GitHub URI first (Lucius, Jan 2023)
600
605
if let Ok ( github_uri) = GithubUri :: try_from ( uri) {
601
606
let status = self . check_github ( github_uri) . await ;
602
607
// Only return Github status in case of success
0 commit comments