[pbs-devel] [PATCH proxmox 10/17] client: switch to hyper/http 1.0

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Mar 26 16:23:14 CET 2025


and adapt to the corresponding proxmox-http changes.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 proxmox-client/Cargo.toml    |  1 +
 proxmox-client/src/client.rs | 22 ++++++++++++----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/proxmox-client/Cargo.toml b/proxmox-client/Cargo.toml
index f890501e..25d41b2b 100644
--- a/proxmox-client/Cargo.toml
+++ b/proxmox-client/Cargo.toml
@@ -14,6 +14,7 @@ repository.workspace = true
 anyhow.workspace = true
 hex.workspace = true
 http.workspace = true
+http-body-util.workspace = true
 serde.workspace = true
 serde_json.workspace = true
 
diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs
index 6f1c9ef1..da2c5c59 100644
--- a/proxmox-client/src/client.rs
+++ b/proxmox-client/src/client.rs
@@ -8,13 +8,14 @@ use http::request::Request;
 use http::uri::PathAndQuery;
 use http::Method;
 use http::{StatusCode, Uri};
-use hyper::body::{Body, HttpBody};
+use http_body_util::BodyExt;
 use openssl::hash::MessageDigest;
 use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
 use openssl::x509::{self, X509};
 use proxmox_login::Ticket;
 use serde::Serialize;
 
+use proxmox_http::Body;
 use proxmox_login::ticket::Validity;
 use proxmox_login::{Login, SecondFactorChallenge, TicketResult};
 
@@ -223,7 +224,7 @@ impl Client {
         // send an `Accept: application/json-seq` header.
         streaming: bool,
         cookie_name: &Option<String>,
-    ) -> Result<(http::response::Parts, hyper::Body), Error> {
+    ) -> Result<(http::response::Parts, Body), Error> {
         let mut request = auth.set_auth_headers_with_cookie_name(
             Request::builder().method(method).uri(uri),
             cookie_name,
@@ -237,7 +238,7 @@ impl Client {
                 .header(http::header::CONTENT_TYPE, "application/json")
                 .body(body.into())
         } else {
-            request.body(Default::default())
+            request.body(Body::empty())
         }
         .map_err(|err| Error::internal("failed to build request", err))?;
 
@@ -449,12 +450,13 @@ impl Client {
     }
 }
 
-async fn read_body(mut body: Body) -> Result<Vec<u8>, Error> {
-    let mut data = Vec::<u8>::new();
-    while let Some(more) = body.data().await {
-        let more = more.map_err(|err| Error::internal("error reading response body", err))?;
-        data.extend(&more[..]);
-    }
+async fn read_body(body: Body) -> Result<Vec<u8>, Error> {
+    let data = body
+        .collect()
+        .await
+        .map_err(Error::Anyhow)?
+        .to_bytes()
+        .to_vec();
     Ok(data)
 }
 
@@ -465,7 +467,7 @@ impl HttpApiClient for Client {
     type ResponseStreamFuture<'a> =
         Pin<Box<dyn Future<Output = Result<HttpApiResponseStream<Self::Body>, Error>> + Send + 'a>>;
 
-    type Body = hyper::Body;
+    type Body = Body;
 
     fn request<'a, T>(
         &'a self,
-- 
2.39.5





More information about the pbs-devel mailing list