[dep-upgrade-202402] prepare migration to http/hyper 1.0

This commit is contained in:
Alex Auvolat 2024-02-05 14:44:12 +01:00
parent 6e4229e29c
commit 6e69a1fffc
No known key found for this signature in database
GPG key ID: 0E496D15096376BE
17 changed files with 67 additions and 94 deletions

View file

@ -2569,8 +2569,10 @@ in
registry = "registry+https://github.com/rust-lang/crates.io-index"; registry = "registry+https://github.com/rust-lang/crates.io-index";
src = fetchCratesIo { inherit name version; sha256 = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"; }; src = fetchCratesIo { inherit name version; sha256 = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"; };
features = builtins.concatLists [ features = builtins.concatLists [
[ "backports" ]
[ "client" ] [ "client" ]
[ "default" ] [ "default" ]
[ "deprecated" ]
(lib.optional (rootFeatures' ? "garage/opentelemetry-otlp" || rootFeatures' ? "garage/telemetry-otlp") "full") (lib.optional (rootFeatures' ? "garage/opentelemetry-otlp" || rootFeatures' ? "garage/telemetry-otlp") "full")
[ "h2" ] [ "h2" ]
[ "http1" ] [ "http1" ]

View file

@ -96,7 +96,7 @@ form_urlencoded = "1.0.0"
http = "0.2" http = "0.2"
httpdate = "1.0" httpdate = "1.0"
http-range = "0.1" http-range = "0.1"
hyper = { version = "0.14", features = ["server", "http1", "runtime", "tcp", "stream"] } hyper = { version = "0.14", features = ["server", "http1", "runtime", "tcp", "stream", "backports", "deprecated"] }
hyperlocal = { version = "0.8.0", default-features = false, features = ["server"] } hyperlocal = { version = "0.8.0", default-features = false, features = ["server"] }
multer = "3.0" multer = "3.0"
percent-encoding = "2.2" percent-encoding = "2.2"

View file

@ -1,4 +1,4 @@
use hyper::{Body, Request, Response}; use hyper::{body::HttpBody, Body, Request, Response};
use idna::domain_to_unicode; use idna::domain_to_unicode;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -139,7 +139,7 @@ pub fn key_after_prefix(pfx: &str) -> Option<String> {
} }
pub async fn parse_json_body<T: for<'de> Deserialize<'de>>(req: Request<Body>) -> Result<T, Error> { pub async fn parse_json_body<T: for<'de> Deserialize<'de>>(req: Request<Body>) -> Result<T, Error> {
let body = hyper::body::to_bytes(req.into_body()).await?; let body = req.into_body().collect().await?.to_bytes();
let resp: T = serde_json::from_slice(&body).ok_or_bad_request("Invalid JSON")?; let resp: T = serde_json::from_slice(&body).ok_or_bad_request("Invalid JSON")?;
Ok(resp) Ok(resp)
} }

View file

@ -3,7 +3,7 @@ use std::sync::Arc;
use base64::prelude::*; use base64::prelude::*;
use http::header; use http::header;
use hyper::{Body, Request, Response, StatusCode}; use hyper::{body::HttpBody, Body, Request, Response, StatusCode};
use garage_util::data::*; use garage_util::data::*;
@ -137,7 +137,8 @@ pub async fn handle_insert_item(
.map(CausalContext::parse_helper) .map(CausalContext::parse_helper)
.transpose()?; .transpose()?;
let body = hyper::body::to_bytes(req.into_body()).await?; let body = req.into_body().collect().await?.to_bytes();
let value = DvvsValue::Value(body.to_vec()); let value = DvvsValue::Value(body.to_vec());
garage garage

View file

@ -1,7 +1,7 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use hyper::{Body, Request, Response, StatusCode}; use hyper::{body::HttpBody, Body, Request, Response, StatusCode};
use garage_model::bucket_alias_table::*; use garage_model::bucket_alias_table::*;
use garage_model::bucket_table::Bucket; use garage_model::bucket_table::Bucket;
@ -119,7 +119,7 @@ pub async fn handle_create_bucket(
api_key: Key, api_key: Key,
bucket_name: String, bucket_name: String,
) -> Result<Response<Body>, Error> { ) -> Result<Response<Body>, Error> {
let body = hyper::body::to_bytes(req.into_body()).await?; let body = req.into_body().collect().await?.to_bytes();
if let Some(content_sha256) = content_sha256 { if let Some(content_sha256) = content_sha256 {
verify_signed_content(content_sha256, &body[..])?; verify_signed_content(content_sha256, &body[..])?;

View file

@ -5,7 +5,7 @@ use http::header::{
ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN,
ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD,
}; };
use hyper::{header::HeaderName, Body, Method, Request, Response, StatusCode}; use hyper::{body::HttpBody, header::HeaderName, Body, Method, Request, Response, StatusCode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -64,7 +64,7 @@ pub async fn handle_put_cors(
req: Request<Body>, req: Request<Body>,
content_sha256: Option<Hash>, content_sha256: Option<Hash>,
) -> Result<Response<Body>, Error> { ) -> Result<Response<Body>, Error> {
let body = hyper::body::to_bytes(req.into_body()).await?; let body = req.into_body().collect().await?.to_bytes();
if let Some(content_sha256) = content_sha256 { if let Some(content_sha256) = content_sha256 {
verify_signed_content(content_sha256, &body[..])?; verify_signed_content(content_sha256, &body[..])?;

View file

@ -1,6 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use hyper::{Body, Request, Response, StatusCode}; use hyper::{body::HttpBody, Body, Request, Response, StatusCode};
use garage_util::data::*; use garage_util::data::*;
@ -75,7 +75,7 @@ pub async fn handle_delete_objects(
req: Request<Body>, req: Request<Body>,
content_sha256: Option<Hash>, content_sha256: Option<Hash>,
) -> Result<Response<Body>, Error> { ) -> Result<Response<Body>, Error> {
let body = hyper::body::to_bytes(req.into_body()).await?; let body = req.into_body().collect().await?.to_bytes();
if let Some(content_sha256) = content_sha256 { if let Some(content_sha256) = content_sha256 {
verify_signed_content(content_sha256, &body[..])?; verify_signed_content(content_sha256, &body[..])?;

View file

@ -1,7 +1,7 @@
use quick_xml::de::from_reader; use quick_xml::de::from_reader;
use std::sync::Arc; use std::sync::Arc;
use hyper::{Body, Request, Response, StatusCode}; use hyper::{body::HttpBody, Body, Request, Response, StatusCode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -57,7 +57,7 @@ pub async fn handle_put_lifecycle(
req: Request<Body>, req: Request<Body>,
content_sha256: Option<Hash>, content_sha256: Option<Hash>,
) -> Result<Response<Body>, Error> { ) -> Result<Response<Body>, Error> {
let body = hyper::body::to_bytes(req.into_body()).await?; let body = req.into_body().collect().await?.to_bytes();
if let Some(content_sha256) = content_sha256 { if let Some(content_sha256) = content_sha256 {
verify_signed_content(content_sha256, &body[..])?; verify_signed_content(content_sha256, &body[..])?;

View file

@ -1,9 +1,9 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use futures::prelude::*; use futures::{prelude::*, TryStreamExt};
use hyper::body::Body; use hyper::body::Body;
use hyper::{Request, Response}; use hyper::{body::HttpBody, Request, Response};
use md5::{Digest as Md5Digest, Md5}; use md5::{Digest as Md5Digest, Md5};
use garage_table::*; use garage_table::*;
@ -87,7 +87,7 @@ pub async fn handle_put_part(
// Read first chuck, and at the same time try to get object to see if it exists // Read first chuck, and at the same time try to get object to see if it exists
let key = key.to_string(); let key = key.to_string();
let body = req.into_body().map_err(Error::from); let body = TryStreamExt::map_err(req.into_body(), Error::from);
let mut chunker = StreamChunker::new(body, garage.config.block_size); let mut chunker = StreamChunker::new(body, garage.config.block_size);
let ((_, _, mut mpu), first_block) = futures::try_join!( let ((_, _, mut mpu), first_block) = futures::try_join!(
@ -217,7 +217,7 @@ pub async fn handle_complete_multipart_upload(
upload_id: &str, upload_id: &str,
content_sha256: Option<Hash>, content_sha256: Option<Hash>,
) -> Result<Response<Body>, Error> { ) -> Result<Response<Body>, Error> {
let body = hyper::body::to_bytes(req.into_body()).await?; let body = HttpBody::collect(req.into_body()).await?.to_bytes();
if let Some(content_sha256) = content_sha256 { if let Some(content_sha256) = content_sha256 {
verify_signed_content(content_sha256, &body[..])?; verify_signed_content(content_sha256, &body[..])?;

View file

@ -1,7 +1,7 @@
use quick_xml::de::from_reader; use quick_xml::de::from_reader;
use std::sync::Arc; use std::sync::Arc;
use hyper::{Body, Request, Response, StatusCode}; use hyper::{body::HttpBody, Body, Request, Response, StatusCode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::s3::error::*; use crate::s3::error::*;
@ -63,7 +63,7 @@ pub async fn handle_put_website(
req: Request<Body>, req: Request<Body>,
content_sha256: Option<Hash>, content_sha256: Option<Hash>,
) -> Result<Response<Body>, Error> { ) -> Result<Response<Body>, Error> {
let body = hyper::body::to_bytes(req.into_body()).await?; let body = req.into_body().collect().await?.to_bytes();
if let Some(content_sha256) = content_sha256 { if let Some(content_sha256) = content_sha256 {
verify_signed_content(content_sha256, &body[..])?; verify_signed_content(content_sha256, &body[..])?;

View file

@ -7,7 +7,7 @@ use base64::prelude::*;
use serde_json::json; use serde_json::json;
use crate::json_body; use crate::json_body;
use hyper::{Method, StatusCode}; use hyper::{body::HttpBody, Method, StatusCode};
#[tokio::test] #[tokio::test]
async fn test_batch() { async fn test_batch() {
@ -77,10 +77,7 @@ async fn test_batch() {
.unwrap() .unwrap()
.to_string(), .to_string(),
); );
let res_body = hyper::body::to_bytes(res.into_body()) let res_body = res.into_body().collect().await.unwrap().to_bytes();
.await
.unwrap()
.to_vec();
assert_eq!(res_body, values.get(sk).unwrap().as_bytes()); assert_eq!(res_body, values.get(sk).unwrap().as_bytes());
} }

View file

@ -7,7 +7,7 @@ use base64::prelude::*;
use serde_json::json; use serde_json::json;
use crate::json_body; use crate::json_body;
use hyper::{Method, StatusCode}; use hyper::{body::HttpBody, Method, StatusCode};
#[tokio::test] #[tokio::test]
async fn test_items_and_indices() { async fn test_items_and_indices() {
@ -83,10 +83,7 @@ async fn test_items_and_indices() {
.to_str() .to_str()
.unwrap() .unwrap()
.to_string(); .to_string();
let res_body = hyper::body::to_bytes(res.into_body()) let res_body = res.into_body().collect().await.unwrap().to_bytes();
.await
.unwrap()
.to_vec();
assert_eq!(res_body, content); assert_eq!(res_body, content);
// ReadIndex -- now there should be some stuff // ReadIndex -- now there should be some stuff
@ -152,10 +149,7 @@ async fn test_items_and_indices() {
res.headers().get("content-type").unwrap().to_str().unwrap(), res.headers().get("content-type").unwrap().to_str().unwrap(),
"application/octet-stream" "application/octet-stream"
); );
let res_body = hyper::body::to_bytes(res.into_body()) let res_body = res.into_body().collect().await.unwrap().to_bytes();
.await
.unwrap()
.to_vec();
assert_eq!(res_body, content2); assert_eq!(res_body, content2);
// ReadIndex -- now there should be some stuff // ReadIndex -- now there should be some stuff
@ -394,10 +388,7 @@ async fn test_item_return_format() {
.to_str() .to_str()
.unwrap() .unwrap()
.to_string(); .to_string();
let res_body = hyper::body::to_bytes(res.into_body()) let res_body = res.into_body().collect().await.unwrap().to_bytes();
.await
.unwrap()
.to_vec();
assert_eq!(res_body, single_value); assert_eq!(res_body, single_value);
// f1: not specified // f1: not specified
@ -434,10 +425,7 @@ async fn test_item_return_format() {
res.headers().get("content-type").unwrap().to_str().unwrap(), res.headers().get("content-type").unwrap().to_str().unwrap(),
"application/octet-stream" "application/octet-stream"
); );
let res_body = hyper::body::to_bytes(res.into_body()) let res_body = res.into_body().collect().await.unwrap().to_bytes();
.await
.unwrap()
.to_vec();
assert_eq!(res_body, single_value); assert_eq!(res_body, single_value);
// f3: json // f3: json

View file

@ -1,5 +1,5 @@
use base64::prelude::*; use base64::prelude::*;
use hyper::{Method, StatusCode}; use hyper::{body::HttpBody, Method, StatusCode};
use std::time::Duration; use std::time::Duration;
use assert_json_diff::assert_json_eq; use assert_json_diff::assert_json_eq;
@ -47,11 +47,8 @@ async fn test_poll_item() {
.unwrap() .unwrap()
.to_string(); .to_string();
let res2_body = hyper::body::to_bytes(res2.into_body()) let res2_body = res2.into_body().collect().await.unwrap().to_bytes();
.await assert_eq!(res2_body, b"Initial value"[..]);
.unwrap()
.to_vec();
assert_eq!(res2_body, b"Initial value");
// Start poll operation // Start poll operation
let poll = { let poll = {
@ -95,11 +92,8 @@ async fn test_poll_item() {
assert_eq!(poll_res.status(), StatusCode::OK); assert_eq!(poll_res.status(), StatusCode::OK);
let poll_res_body = hyper::body::to_bytes(poll_res.into_body()) let poll_res_body = poll_res.into_body().collect().await.unwrap().to_bytes();
.await assert_eq!(poll_res_body, b"New value"[..]);
.unwrap()
.to_vec();
assert_eq!(poll_res_body, b"New value");
} }
#[tokio::test] #[tokio::test]

View file

@ -1,6 +1,6 @@
use crate::common; use crate::common;
use hyper::{Method, StatusCode}; use hyper::{body::HttpBody, Method, StatusCode};
#[tokio::test] #[tokio::test]
async fn test_simple() { async fn test_simple() {
@ -32,9 +32,6 @@ async fn test_simple() {
.unwrap(); .unwrap();
assert_eq!(res2.status(), StatusCode::OK); assert_eq!(res2.status(), StatusCode::OK);
let res2_body = hyper::body::to_bytes(res2.into_body()) let res2_body = res2.into_body().collect().await.unwrap().to_bytes();
.await assert_eq!(res2_body, b"Hello, world!"[..]);
.unwrap()
.to_vec();
assert_eq!(res2_body, b"Hello, world!");
} }

View file

@ -11,15 +11,10 @@ mod k2v;
#[cfg(feature = "k2v")] #[cfg(feature = "k2v")]
mod k2v_client; mod k2v_client;
use hyper::{Body, Response}; use hyper::{body::HttpBody, Body, Response};
pub async fn json_body(res: Response<Body>) -> serde_json::Value { pub async fn json_body(res: Response<Body>) -> serde_json::Value {
let res_body: serde_json::Value = serde_json::from_slice( let body = res.into_body().collect().await.unwrap().to_bytes();
&hyper::body::to_bytes(res.into_body()) let res_body: serde_json::Value = serde_json::from_slice(&body).unwrap();
.await
.unwrap()
.to_vec()[..],
)
.unwrap();
res_body res_body
} }

View file

@ -9,7 +9,7 @@ use aws_sdk_s3::{
}; };
use http::{Request, StatusCode}; use http::{Request, StatusCode};
use hyper::{ use hyper::{
body::{to_bytes, Body}, body::{Body, HttpBody},
Client, Client,
}; };
use serde_json::json; use serde_json::json;
@ -49,7 +49,7 @@ async fn test_website() {
assert_eq!(resp.status(), StatusCode::NOT_FOUND); assert_eq!(resp.status(), StatusCode::NOT_FOUND);
assert_ne!( assert_ne!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(), resp.into_body().collect().await.unwrap().to_bytes(),
BODY.as_ref() BODY.as_ref()
); /* check that we do not leak body */ ); /* check that we do not leak body */
@ -87,7 +87,7 @@ async fn test_website() {
resp = client.request(req()).await.unwrap(); resp = client.request(req()).await.unwrap();
assert_eq!(resp.status(), StatusCode::OK); assert_eq!(resp.status(), StatusCode::OK);
assert_eq!( assert_eq!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(), resp.into_body().collect().await.unwrap().to_bytes(),
BODY.as_ref() BODY.as_ref()
); );
@ -107,10 +107,10 @@ async fn test_website() {
.unwrap() .unwrap()
}; };
let mut admin_resp = client.request(admin_req()).await.unwrap(); let admin_resp = client.request(admin_req()).await.unwrap();
assert_eq!(admin_resp.status(), StatusCode::OK); assert_eq!(admin_resp.status(), StatusCode::OK);
assert_eq!( assert_eq!(
to_bytes(admin_resp.body_mut()).await.unwrap().as_ref(), admin_resp.into_body().collect().await.unwrap().to_bytes(),
format!("Domain '{bname}' is managed by Garage").as_bytes() format!("Domain '{bname}' is managed by Garage").as_bytes()
); );
} }
@ -124,7 +124,7 @@ async fn test_website() {
resp = client.request(req()).await.unwrap(); resp = client.request(req()).await.unwrap();
assert_eq!(resp.status(), StatusCode::NOT_FOUND); assert_eq!(resp.status(), StatusCode::NOT_FOUND);
assert_ne!( assert_ne!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(), resp.into_body().collect().await.unwrap().to_bytes(),
BODY.as_ref() BODY.as_ref()
); /* check that we do not leak body */ ); /* check that we do not leak body */
@ -260,7 +260,7 @@ async fn test_website_s3_api() {
.body(Body::empty()) .body(Body::empty())
.unwrap(); .unwrap();
let mut resp = client.request(req).await.unwrap(); let resp = client.request(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::OK); assert_eq!(resp.status(), StatusCode::OK);
assert_eq!( assert_eq!(
@ -268,7 +268,7 @@ async fn test_website_s3_api() {
"*" "*"
); );
assert_eq!( assert_eq!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(), resp.into_body().collect().await.unwrap().to_bytes(),
BODY.as_ref() BODY.as_ref()
); );
} }
@ -285,11 +285,11 @@ async fn test_website_s3_api() {
.body(Body::empty()) .body(Body::empty())
.unwrap(); .unwrap();
let mut resp = client.request(req).await.unwrap(); let resp = client.request(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::NOT_FOUND); assert_eq!(resp.status(), StatusCode::NOT_FOUND);
assert_eq!( assert_eq!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(), resp.into_body().collect().await.unwrap().to_bytes(),
BODY_ERR.as_ref() BODY_ERR.as_ref()
); );
} }
@ -305,7 +305,7 @@ async fn test_website_s3_api() {
.body(Body::empty()) .body(Body::empty())
.unwrap(); .unwrap();
let mut resp = client.request(req).await.unwrap(); let resp = client.request(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::OK); assert_eq!(resp.status(), StatusCode::OK);
assert_eq!( assert_eq!(
@ -313,7 +313,7 @@ async fn test_website_s3_api() {
"*" "*"
); );
assert_ne!( assert_ne!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(), resp.into_body().collect().await.unwrap().to_bytes(),
BODY.as_ref() BODY.as_ref()
); );
} }
@ -329,11 +329,11 @@ async fn test_website_s3_api() {
.body(Body::empty()) .body(Body::empty())
.unwrap(); .unwrap();
let mut resp = client.request(req).await.unwrap(); let resp = client.request(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::FORBIDDEN); assert_eq!(resp.status(), StatusCode::FORBIDDEN);
assert_ne!( assert_ne!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(), resp.into_body().collect().await.unwrap().to_bytes(),
BODY.as_ref() BODY.as_ref()
); );
} }
@ -370,11 +370,11 @@ async fn test_website_s3_api() {
.body(Body::empty()) .body(Body::empty())
.unwrap(); .unwrap();
let mut resp = client.request(req).await.unwrap(); let resp = client.request(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::FORBIDDEN); assert_eq!(resp.status(), StatusCode::FORBIDDEN);
assert_ne!( assert_ne!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(), resp.into_body().collect().await.unwrap().to_bytes(),
BODY.as_ref() BODY.as_ref()
); );
} }
@ -396,17 +396,12 @@ async fn test_website_s3_api() {
.body(Body::empty()) .body(Body::empty())
.unwrap(); .unwrap();
let mut resp = client.request(req).await.unwrap(); let resp = client.request(req).await.unwrap();
assert_eq!(resp.status(), StatusCode::NOT_FOUND); assert_eq!(resp.status(), StatusCode::NOT_FOUND);
assert_ne!( let resp_bytes = resp.into_body().collect().await.unwrap().to_bytes();
to_bytes(resp.body_mut()).await.unwrap().as_ref(), assert_ne!(resp_bytes, BODY_ERR.as_ref());
BODY_ERR.as_ref() assert_ne!(resp_bytes, BODY.as_ref());
);
assert_ne!(
to_bytes(resp.body_mut()).await.unwrap().as_ref(),
BODY.as_ref()
);
} }
} }

View file

@ -9,7 +9,7 @@ use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};
use http::header::{ACCEPT, CONTENT_TYPE}; use http::header::{ACCEPT, CONTENT_TYPE};
use http::status::StatusCode; use http::status::StatusCode;
use http::{HeaderName, HeaderValue, Request}; 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::{client::connect::HttpConnector, Client as HttpClient};
use hyper_rustls::HttpsConnector; use hyper_rustls::HttpsConnector;
@ -416,12 +416,16 @@ impl K2vClient {
}; };
let body = match res.status { 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::NO_CONTENT => Bytes::new(),
StatusCode::NOT_FOUND => return Err(Error::NotFound), StatusCode::NOT_FOUND => return Err(Error::NotFound),
StatusCode::NOT_MODIFIED => Bytes::new(), StatusCode::NOT_MODIFIED => Bytes::new(),
s => { 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) let err_body_str = std::str::from_utf8(&err_body)
.map(String::from) .map(String::from)
.unwrap_or_else(|_| BASE64_STANDARD.encode(&err_body)); .unwrap_or_else(|_| BASE64_STANDARD.encode(&err_body));