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/api | |
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/api')
-rw-r--r-- | src/api/helpers.rs | 4 | ||||
-rw-r--r-- | src/api/k2v/item.rs | 5 | ||||
-rw-r--r-- | src/api/s3/bucket.rs | 4 | ||||
-rw-r--r-- | src/api/s3/cors.rs | 4 | ||||
-rw-r--r-- | src/api/s3/delete.rs | 4 | ||||
-rw-r--r-- | src/api/s3/lifecycle.rs | 4 | ||||
-rw-r--r-- | src/api/s3/multipart.rs | 8 | ||||
-rw-r--r-- | src/api/s3/website.rs | 4 |
8 files changed, 19 insertions, 18 deletions
diff --git a/src/api/helpers.rs b/src/api/helpers.rs index 1d55ebd5..8efaa231 100644 --- a/src/api/helpers.rs +++ b/src/api/helpers.rs @@ -1,4 +1,4 @@ -use hyper::{Body, Request, Response}; +use hyper::{body::HttpBody, Body, Request, Response}; use idna::domain_to_unicode; 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> { - 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")?; Ok(resp) } diff --git a/src/api/k2v/item.rs b/src/api/k2v/item.rs index e13a0f30..33f4da53 100644 --- a/src/api/k2v/item.rs +++ b/src/api/k2v/item.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use base64::prelude::*; use http::header; -use hyper::{Body, Request, Response, StatusCode}; +use hyper::{body::HttpBody, Body, Request, Response, StatusCode}; use garage_util::data::*; @@ -137,7 +137,8 @@ pub async fn handle_insert_item( .map(CausalContext::parse_helper) .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()); garage diff --git a/src/api/s3/bucket.rs b/src/api/s3/bucket.rs index 733981e1..a2437524 100644 --- a/src/api/s3/bucket.rs +++ b/src/api/s3/bucket.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; 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_table::Bucket; @@ -119,7 +119,7 @@ pub async fn handle_create_bucket( api_key: Key, bucket_name: String, ) -> 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 { verify_signed_content(content_sha256, &body[..])?; diff --git a/src/api/s3/cors.rs b/src/api/s3/cors.rs index 49097ad1..d2bcf125 100644 --- a/src/api/s3/cors.rs +++ b/src/api/s3/cors.rs @@ -5,7 +5,7 @@ use http::header::{ ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, 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}; @@ -64,7 +64,7 @@ pub async fn handle_put_cors( req: Request<Body>, content_sha256: Option<Hash>, ) -> 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 { verify_signed_content(content_sha256, &body[..])?; diff --git a/src/api/s3/delete.rs b/src/api/s3/delete.rs index 1c491eac..685ce004 100644 --- a/src/api/s3/delete.rs +++ b/src/api/s3/delete.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use hyper::{Body, Request, Response, StatusCode}; +use hyper::{body::HttpBody, Body, Request, Response, StatusCode}; use garage_util::data::*; @@ -75,7 +75,7 @@ pub async fn handle_delete_objects( req: Request<Body>, content_sha256: Option<Hash>, ) -> 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 { verify_signed_content(content_sha256, &body[..])?; diff --git a/src/api/s3/lifecycle.rs b/src/api/s3/lifecycle.rs index 1e7d6755..ae8fbc37 100644 --- a/src/api/s3/lifecycle.rs +++ b/src/api/s3/lifecycle.rs @@ -1,7 +1,7 @@ use quick_xml::de::from_reader; use std::sync::Arc; -use hyper::{Body, Request, Response, StatusCode}; +use hyper::{body::HttpBody, Body, Request, Response, StatusCode}; use serde::{Deserialize, Serialize}; @@ -57,7 +57,7 @@ pub async fn handle_put_lifecycle( req: Request<Body>, content_sha256: Option<Hash>, ) -> 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 { verify_signed_content(content_sha256, &body[..])?; diff --git a/src/api/s3/multipart.rs b/src/api/s3/multipart.rs index 6b786318..96c4d044 100644 --- a/src/api/s3/multipart.rs +++ b/src/api/s3/multipart.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; use std::sync::Arc; -use futures::prelude::*; +use futures::{prelude::*, TryStreamExt}; use hyper::body::Body; -use hyper::{Request, Response}; +use hyper::{body::HttpBody, Request, Response}; use md5::{Digest as Md5Digest, Md5}; 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 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 mpu), first_block) = futures::try_join!( @@ -217,7 +217,7 @@ pub async fn handle_complete_multipart_upload( upload_id: &str, content_sha256: Option<Hash>, ) -> 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 { verify_signed_content(content_sha256, &body[..])?; diff --git a/src/api/s3/website.rs b/src/api/s3/website.rs index 7f2ab925..f754ff1b 100644 --- a/src/api/s3/website.rs +++ b/src/api/s3/website.rs @@ -1,7 +1,7 @@ use quick_xml::de::from_reader; use std::sync::Arc; -use hyper::{Body, Request, Response, StatusCode}; +use hyper::{body::HttpBody, Body, Request, Response, StatusCode}; use serde::{Deserialize, Serialize}; use crate::s3::error::*; @@ -63,7 +63,7 @@ pub async fn handle_put_website( req: Request<Body>, content_sha256: Option<Hash>, ) -> 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 { verify_signed_content(content_sha256, &body[..])?; |