Skip to content

Commit

Permalink
Merge pull request #4 from spacemeshos/dont-follow-redirect
Browse files Browse the repository at this point in the history
Do not follow redirect on checking layer in trusted db
  • Loading branch information
brusherru authored Feb 29, 2024
2 parents 4ea4c83 + 7e9013d commit 6896ca9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quicksync"
version = "0.1.6"
version = "0.1.7"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
8 changes: 5 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{anyhow, Result};
use chrono::{DateTime, Duration, Utc};
use regex::Regex;
use reqwest::blocking::Client;
use reqwest::{blocking::Client, redirect};
use std::{env, path::PathBuf};
use url::Url;

Expand Down 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::parse(location)?;
let num = extract_number_from_url(&final_url)?;

Ok(num)
}
Expand Down

0 comments on commit 6896ca9

Please sign in to comment.