From dee45f4b81de8b092d8ae75be32845d6789347f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= <felix@passcod.name>
Date: Tue, 31 May 2022 23:18:45 +1200
Subject: [PATCH] Correct HTTP error for remote_exists() helper

---
 src/helpers.rs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/helpers.rs b/src/helpers.rs
index d6be62de..3501532c 100644
--- a/src/helpers.rs
+++ b/src/helpers.rs
@@ -29,8 +29,13 @@ pub fn load_manifest_path<P: AsRef<Path>>(
     Ok(manifest)
 }
 
-pub async fn remote_exists(url: &str, method: reqwest::Method) -> Result<bool, BinstallError> {
-    let req = reqwest::Client::new().request(method, url).send().await?;
+pub async fn remote_exists(url: &str, method: Method) -> Result<bool, BinstallError> {
+    let url = Url::parse(url)?;
+    let req = reqwest::Client::new()
+        .request(method.clone(), url.clone())
+        .send()
+        .await
+        .map_err(|err| BinstallError::Http { method, url, err })?;
     Ok(req.status().is_success())
 }