Skip to content

Commit

Permalink
tweak: do not follow redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
brusherru committed Feb 28, 2024
1 parent 4ea4c83 commit 7ee223b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fn extract_number_from_url(url: &Url) -> Result<u64> {

pub fn fetch_latest_available_layer(download_url: &Url, go_version: &str) -> Result<u64> {
let client = Client::builder()
.redirect(redirect::Policy::none())
.timeout(std::time::Duration::from_secs(30))
.build()?;

Expand All @@ -81,8 +82,9 @@ pub fn fetch_latest_available_layer(download_url: &Url, go_version: &str) -> Res

let response = client.head(url).send()?;

let final_url = response.url();
let num = extract_number_from_url(final_url)?;
let location = response.headers().get("location").unwrap().to_str()?;
let final_url = Url::from_str(location)?;
let num = extract_number_from_url(&final_url)?;

Ok(num)
}
Expand Down

0 comments on commit 7ee223b

Please sign in to comment.