[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
17 changed files with 67 additions and 94 deletions
+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 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)
}
+3 -2
View File
@@ -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
+2 -2
View File
@@ -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[..])?;
+2 -2
View File
@@ -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[..])?;
+2 -2
View File
@@ -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[..])?;
+2 -2
View File
@@ -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[..])?;
+4 -4
View File
@@ -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[..])?;
+2 -2
View File
@@ -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[..])?;