diff --git a/src/utils.rs b/src/utils.rs index c00969f..64db4be 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -73,6 +73,7 @@ fn extract_number_from_url(url: &Url) -> Result { pub fn fetch_latest_available_layer(download_url: &Url, go_version: &str) -> Result { let client = Client::builder() + .redirect(redirect::Policy::none()) .timeout(std::time::Duration::from_secs(30)) .build()?; @@ -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) }