mirror of
https://github.com/Hopiu/lychee.git
synced 2026-03-17 05:00:26 +00:00
Add credentials to chain
This commit is contained in:
parent
3ec3a8228c
commit
41e7f88da4
3 changed files with 13 additions and 7 deletions
|
|
@ -8,7 +8,7 @@ use http::StatusCode;
|
|||
use reqwest::Request;
|
||||
use std::{collections::HashSet, time::Duration};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct Checker {
|
||||
retry_wait_time: Duration,
|
||||
max_retries: u64,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ use crate::{
|
|||
quirks::Quirks,
|
||||
remap::Remaps,
|
||||
types::uri::github::GithubUri,
|
||||
utils::fragment_checker::FragmentChecker, ErrorKind, Request, Response, Result, Status, Uri,
|
||||
utils::fragment_checker::FragmentChecker,
|
||||
ErrorKind, Request, Response, Result, Status, Uri,
|
||||
};
|
||||
|
||||
#[cfg(all(feature = "email-check", feature = "native-tls"))]
|
||||
|
|
@ -465,7 +466,7 @@ impl Client {
|
|||
{
|
||||
let Request {
|
||||
ref mut uri,
|
||||
ref credentials,
|
||||
credentials,
|
||||
source,
|
||||
..
|
||||
} = request.try_into()?;
|
||||
|
|
@ -486,7 +487,9 @@ impl Client {
|
|||
}
|
||||
|
||||
let request_chain: RequestChain = Chain::new(vec![
|
||||
// TODO: insert self.request_chain
|
||||
Box::<Quirks>::default(),
|
||||
Box::new(credentials),
|
||||
Box::new(Checker::new(
|
||||
self.retry_wait_time,
|
||||
self.max_retries,
|
||||
|
|
|
|||
|
|
@ -75,11 +75,14 @@ impl BasicAuthCredentials {
|
|||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Chainable<Request, Status> for BasicAuthCredentials {
|
||||
impl Chainable<Request, Status> for Option<BasicAuthCredentials> {
|
||||
async fn chain(&mut self, mut request: Request) -> ChainResult<Request, Status> {
|
||||
request
|
||||
.headers_mut()
|
||||
.append(AUTHORIZATION, self.to_authorization().0.encode());
|
||||
if let Some(credentials) = self {
|
||||
request
|
||||
.headers_mut()
|
||||
.append(AUTHORIZATION, credentials.to_authorization().0.encode());
|
||||
}
|
||||
|
||||
ChainResult::Next(request)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue