From a075e305578d4137548263aedc1c294a7dad00f8 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 1 May 2026 17:58:35 -0400 Subject: [PATCH] http: add HttpResponse::bytes() for binary downloads Mirror of text(), but returns raw Bytes without lossy UTF-8 conversion. Needed by the Telegram channel to fetch photo files. Co-Authored-By: Proof of Concept --- src/agent/api/http.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/agent/api/http.rs b/src/agent/api/http.rs index 65b759b..a059426 100644 --- a/src/agent/api/http.rs +++ b/src/agent/api/http.rs @@ -154,6 +154,14 @@ impl HttpResponse { Ok(String::from_utf8_lossy(&bytes).into_owned()) } + /// Read the entire body as raw bytes (for binary downloads). + pub async fn bytes(self) -> Result { + let bytes = self.body.collect().await + .context("reading response body")? + .to_bytes(); + Ok(bytes) + } + /// Read the entire body and deserialize as JSON. pub async fn json(self) -> Result { let bytes = self.body.collect().await