From 7ee223b9f88378d83185601827943af88e33ad44 Mon Sep 17 00:00:00 2001 From: brusher_ru Date: Wed, 28 Feb 2024 23:48:54 +0700 Subject: [PATCH] tweak: do not follow redirect --- src/utils.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) }