aboutsummaryrefslogtreecommitdiff
path: root/src/garage/tests/common/custom_requester.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-05 19:57:35 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-05 19:57:35 +0100
commit81ccd4586ebdf707dfd37d4802e0cf475e11e004 (patch)
tree66355871fc313bf4cdde0866b335b4408597745d /src/garage/tests/common/custom_requester.rs
parenta22bd319202f05bce4ad13072238c7ba81d518fb (diff)
downloadgarage-81ccd4586ebdf707dfd37d4802e0cf475e11e004.tar.gz
garage-81ccd4586ebdf707dfd37d4802e0cf475e11e004.zip
[dep-upgrade-202402] upgrade to http/hyper 1.x for tests
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))
}
}