1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 10:41:03 +02:00

fix(image): http provider not handling non-success codes

This commit is contained in:
Jake Stanger 2023-04-10 20:05:13 +01:00
parent c214f65ecb
commit 7355db74ec
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61

View file

@ -193,7 +193,16 @@ impl<'a> ImageProvider<'a> {
/// Attempts to get `Bytes` from an HTTP resource asynchronously.
#[cfg(feature = "http")]
async fn get_bytes_from_http(url: reqwest::Url) -> Result<glib::Bytes> {
let bytes = reqwest::get(url).await?.bytes().await?;
Ok(glib::Bytes::from_owned(bytes))
let res = reqwest::get(url).await?;
let status = res.status();
if status.is_success() {
let bytes = res.bytes().await?;
Ok(glib::Bytes::from_owned(bytes))
} else {
Err(Report::msg(format!(
"Received non-success HTTP code ({status})"
)))
}
}
}