summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-07-01 10:30:22 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-08-31 08:49:42 +0200
commit150311c1fa9cb3ac7b9e9a732c2c503c718b3a39 (patch)
treead70d1950863585deb2154ab2c91cd00e9e59905
parente8a2eb1dd6d0b22292f76e17d05ffd68bd52346d (diff)
Fix: Follow HTTP redirects
This patch fixes the reqwest GET call by building a Client and a Request object configured to follow HTTP redirects (10 by now, maybe this will later need to be configurable). This patch was backported from commit d2cc4a734a808afc4a2fc0f8661d65090e8ccffb Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r--src/commands/source.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/commands/source.rs b/src/commands/source.rs
index 6a58017..505e7dd 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -270,7 +270,15 @@ pub async fn download(
})?;
let mut file = tokio::io::BufWriter::new(file);
- let response = match reqwest::get(source.url().as_ref()).await {
+ let client = reqwest::Client::builder()
+ .redirect(reqwest::redirect::Policy::limited(10))
+ .build()
+ .context("BUilding HTTP client failed")?;
+ let request = client.get(source.url().as_ref())
+ .build()
+ .with_context(|| anyhow!("Building request for {} failed", source.url().as_ref()))?;
+
+ let response = match client.execute(request).await {
Ok(resp) => resp,
Err(e) => {
bar.finish_with_message(format!("Failed: {}", source.url()));