diff options
author | Alex Auvolat <alex@adnab.me> | 2024-02-05 14:44:12 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2024-02-05 14:44:12 +0100 |
commit | 6e69a1fffc715c752a399750c1e26aa46683dbb2 (patch) | |
tree | d1539c6107372f14aa6ca09255977df69411a553 /src/k2v-client | |
parent | 6e4229e29c1ee3e0b7f3511f80b6108e3beb1efd (diff) | |
download | garage-6e69a1fffc715c752a399750c1e26aa46683dbb2.tar.gz garage-6e69a1fffc715c752a399750c1e26aa46683dbb2.zip |
[dep-upgrade-202402] prepare migration to http/hyper 1.0
Diffstat (limited to 'src/k2v-client')
-rw-r--r-- | src/k2v-client/lib.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/k2v-client/lib.rs b/src/k2v-client/lib.rs index 4977ce85..f70442f4 100644 --- a/src/k2v-client/lib.rs +++ b/src/k2v-client/lib.rs @@ -9,7 +9,7 @@ use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC}; use http::header::{ACCEPT, CONTENT_TYPE}; use http::status::StatusCode; use http::{HeaderName, HeaderValue, Request}; -use hyper::{body::Bytes, Body}; +use hyper::{body::Bytes, body::HttpBody, Body}; use hyper::{client::connect::HttpConnector, Client as HttpClient}; use hyper_rustls::HttpsConnector; @@ -416,12 +416,16 @@ impl K2vClient { }; let body = match res.status { - StatusCode::OK => hyper::body::to_bytes(body).await?, + StatusCode::OK => body.collect().await?.to_bytes(), StatusCode::NO_CONTENT => Bytes::new(), StatusCode::NOT_FOUND => return Err(Error::NotFound), StatusCode::NOT_MODIFIED => Bytes::new(), s => { - let err_body = hyper::body::to_bytes(body).await.unwrap_or_default(); + let err_body = body + .collect() + .await + .map(|x| x.to_bytes()) + .unwrap_or_default(); let err_body_str = std::str::from_utf8(&err_body) .map(String::from) .unwrap_or_else(|_| BASE64_STANDARD.encode(&err_body)); |