Skip to content

Commit

Permalink
fix(https): conditionally apply basic authentication for non-anonymou…
Browse files Browse the repository at this point in the history
…s users (#3772)
  • Loading branch information
Sma1lboy authored Jan 31, 2025
1 parent 8897506 commit 9641479
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/aim-downloader/src/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl HTTPSHandler {
let parsed_address = ParsedAddress::parse_address(input, bar.silent);
let (mut out, mut downloaded) = io::get_output(output, bar.silent);

let res = Client::new()
let mut request = Client::new()
.get(input)
.header(
"Range",
Expand All @@ -131,8 +131,13 @@ impl HTTPSHandler {
.header(
reqwest::header::USER_AGENT,
reqwest::header::HeaderValue::from_static(CLIENT_ID),
)
.basic_auth(parsed_address.username, Some(parsed_address.password))
);

if parsed_address.password != "anonymous" {
request = request.basic_auth(parsed_address.username, Some(parsed_address.password));
}

let res = request
.send()
.await
.and_then(|r| r.error_for_status())
Expand Down

0 comments on commit 9641479

Please sign in to comment.