summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-07-01 10:30:22 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-07-01 10:30:24 +0200
commitd2cc4a734a808afc4a2fc0f8661d65090e8ccffb (patch)
treed25ff401a79dac708863380172a338d36daaffed
parent4b2ecab8aa60b11c4eef37e306a863be4679899d (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). Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r--src/commands/source.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/commands/source.rs b/src/commands/source.rs
index 36cf352..3ad7f5d 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -224,7 +224,16 @@ 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()));