aboutsummaryrefslogtreecommitdiff
path: root/src/garage/tests/common/custom_requester.rs
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2024-02-07 14:59:40 +0000
committerAlex <alex@adnab.me>2024-02-07 14:59:40 +0000
commit5d941e0100489fff552b59f0679a2a010403a21c (patch)
tree5c5cef9af72d48dd7347922341e43f0013380c60 /src/garage/tests/common/custom_requester.rs
parentfeeb076b7f5db7fe6fdbe3d2903fae054cde6219 (diff)
parente011941964b1c1e0b90f85014d166d64a83ae8e2 (diff)
downloadgarage-5d941e0100489fff552b59f0679a2a010403a21c.tar.gz
garage-5d941e0100489fff552b59f0679a2a010403a21c.zip
Merge pull request 'Dependency upgrades: http, hyper, aws-sdk, smaller deps' (#703) from dep-upgrade-202402 into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/703
Diffstat (limited to 'src/garage/tests/common/custom_requester.rs')
-rw-r--r--src/garage/tests/common/custom_requester.rs34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/garage/tests/common/custom_requester.rs b/src/garage/tests/common/custom_requester.rs
index 4133bb8b..72fb1a46 100644
--- a/src/garage/tests/common/custom_requester.rs
+++ b/src/garage/tests/common/custom_requester.rs
@@ -5,12 +5,17 @@ use std::convert::TryFrom;
use chrono::{offset::Utc, DateTime};
use hmac::{Hmac, Mac};
-use hyper::client::HttpConnector;
-use hyper::{Body, Client, Method, Request, Response, Uri};
+use http_body_util::BodyExt;
+use http_body_util::Full as FullBody;
+use hyper::{Method, Request, Response, Uri};
+use hyper_util::client::legacy::{connect::HttpConnector, Client};
+use hyper_util::rt::TokioExecutor;
use super::garage::{Instance, Key};
use garage_api::signature;
+pub type Body = FullBody<hyper::body::Bytes>;
+
/// You should ever only use this to send requests AWS sdk won't send,
/// like to reproduce behavior of unusual implementations found to be
/// problematic.
@@ -19,7 +24,7 @@ pub struct CustomRequester {
key: Key,
uri: Uri,
service: &'static str,
- client: Client<HttpConnector>,
+ client: Client<HttpConnector, Body>,
}
impl CustomRequester {
@@ -28,7 +33,7 @@ impl CustomRequester {
key: key.clone(),
uri: instance.s3_uri(),
service: "s3",
- client: Client::new(),
+ client: Client::builder(TokioExecutor::new()).build_http(),
}
}
@@ -37,7 +42,7 @@ impl CustomRequester {
key: key.clone(),
uri: instance.k2v_uri(),
service: "k2v",
- client: Client::new(),
+ client: Client::builder(TokioExecutor::new()).build_http(),
}
}
@@ -139,7 +144,7 @@ impl<'a> RequestBuilder<'a> {
self
}
- pub async fn send(&mut self) -> hyper::Result<Response<Body>> {
+ pub async fn send(&mut self) -> Result<Response<Body>, String> {
// TODO this is a bit incorrect in that path and query params should be url-encoded and
// aren't, but this is good enought for now.
@@ -242,7 +247,22 @@ impl<'a> RequestBuilder<'a> {
.method(self.method.clone())
.body(Body::from(body))
.unwrap();
- self.requester.client.request(request).await
+
+ let result = self
+ .requester
+ .client
+ .request(request)
+ .await
+ .map_err(|err| format!("hyper client error: {}", err))?;
+
+ let (head, body) = result.into_parts();
+ let body = Body::new(
+ body.collect()
+ .await
+ .map_err(|err| format!("hyper client error in body.collect: {}", err))?
+ .to_bytes(),
+ );
+ Ok(Response::from_parts(head, body))
}
}