From 40c88cd4603059213928d8c85d60d7dc4786bc92 Mon Sep 17 00:00:00 2001
From: Emanuele Aina <emanuele.aina@collabora.com>
Date: Tue, 17 May 2022 15:41:40 +0200
Subject: [PATCH] storage_stats: Actually check the HTTP status code

By default reqwest does not return an actual error for non-success HTTP
status codes like HTTP 404.

This lead to parser failures when trying to read the HTML error message
from a 404 reply as a deb822 document.

Use `Response::error_for_status()` to actually check for successful
status codes.

Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
---
 storage_stats/src/client.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/storage_stats/src/client.rs b/storage_stats/src/client.rs
index e54adb2..fa557ba 100644
--- a/storage_stats/src/client.rs
+++ b/storage_stats/src/client.rs
@@ -54,7 +54,7 @@ impl Client {
 
         // NOTE: the URL should be printed since get() is instrumented.
         debug!("GET");
-        Ok(self.client.get(url.clone()).send().await?.bytes().await?)
+        Ok(self.client.get(url.clone()).send().await?.error_for_status().bytes().await?)
     }
 
     #[instrument(skip(self))]
-- 
GitLab