Correct HTTP error for remote_exists() helper

This commit is contained in:
Félix Saparelli 2022-05-31 23:18:45 +12:00
parent c83c184983
commit dee45f4b81
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474

View file

@ -29,8 +29,13 @@ pub fn load_manifest_path<P: AsRef<Path>>(
Ok(manifest) Ok(manifest)
} }
pub async fn remote_exists(url: &str, method: reqwest::Method) -> Result<bool, BinstallError> { pub async fn remote_exists(url: &str, method: Method) -> Result<bool, BinstallError> {
let req = reqwest::Client::new().request(method, url).send().await?; 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()) Ok(req.status().is_success())
} }