Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Update all hyper/http/http-body instances to >1 #790

Open
3 of 6 tasks
jsantell opened this issue Jan 22, 2024 · 1 comment
Open
3 of 6 tasks

Update all hyper/http/http-body instances to >1 #790

jsantell opened this issue Jan 22, 2024 · 1 comment
Labels
Chore Non-user-facing feature dependencies Pull requests that update a dependency file

Comments

@jsantell
Copy link
Contributor

jsantell commented Jan 22, 2024

With axum updated to >0.7 (#778), we're using the lower level components http, hyper, http-body at their 1.0+ releases. In tree, we're still using [email protected] and older http/http-body deps. Focusing on hyper here, but http and http-body deps should also be >1.0.

@jsantell jsantell added Chore Non-user-facing feature dependencies Pull requests that update a dependency file labels Jan 22, 2024
@jsantell
Copy link
Contributor Author

Attempting to update hyper to 1 in noosphere-ipfs (#822) requires some changes; these get us close:

-hyper = { version = "^0.14.27", features = ["full"] }
+bytes = { workspace = true }
+http-body-util = { workspace = true }
+hyper = { version = "^1.1.0", features = ["full"] }
+hyper-util = { version = "0.1.3", features = ["client", "client-legacy", "http1"] }
-use hyper::{
-    client::connect::dns::GaiResolver, client::HttpConnector, Body, Client, Request, StatusCode,
-};
+use http_body_util::{BodyExt, Empty, Full};
+use hyper::{Request, StatusCode};
 use hyper_multipart_rfc7578::client::multipart::{Body as MultipartBody, Form};
+use hyper_util::{
+    client::legacy::{
+        connect::{dns::GaiResolver, HttpConnector},
+        Client,
+    },
+    rt::TokioExecutor,
+};
 use tokio_util::compat::TokioAsyncReadCompatExt;
 // TODO(#587): Remove dependency on `ipfs-api` crate
 use ipfs_api_prelude::response::{PinAddResponse, PinLsResponse};
@@ -43,14 +49,14 @@ const KUBO_DAG_IMPORT_TIMEOUT: Duration = Duration::from_secs(60);
 /// their expected payloads to Noosphere-friendly formats
 #[derive(Clone, Debug)]
 pub struct KuboClient {
-    client: Client<HttpConnector<GaiResolver>>,
+    client: Client<HttpConnector<GaiResolver>, Empty<Bytes>>,
     api_url: Url,
 }
 
 impl KuboClient {
     // TODO: This probably doesn't need to return a result
     pub fn new(api_url: &Url) -> Result<Self> {
-        let client = hyper::Client::builder().build_http();
+        let client = Client::builder(TokioExecutor::new()).build_http();
         Ok(KuboClient {
             client,
             api_url: api_url.clone(),
@@ -76,10 +82,10 @@ impl IpfsClient for KuboClient {
             let request = Request::builder()
                 .method("POST")
                 .uri(&api_url.to_string())
-                .body(Body::empty())?;
+                .body(Empty::new())?;
             let response = self.client.request(request).await?;
 
-            let body_bytes = hyper::body::to_bytes(response.into_body()).await?;
+            let body_bytes = response.into_body().collect().await?.to_bytes();

TBD between Full and Empty helper bodies. Shelved for now after needing hyper-multipart-rfc7578 to also support hyper 1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Chore Non-user-facing feature dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

1 participant