From f22ecb60a8e1848de95e1bd3104b0ceec7058f0c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 7 Jul 2020 17:15:53 +0200 Subject: Update to Hyper 0.13.6 that accepts non-Sync streams in wrap_stream. Simplifies code and makes it possible to publish on crates.io --- src/api/api_server.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/api/api_server.rs') diff --git a/src/api/api_server.rs b/src/api/api_server.rs index 699dc5c4..92a9f2a6 100644 --- a/src/api/api_server.rs +++ b/src/api/api_server.rs @@ -11,7 +11,6 @@ use garage_util::error::Error; use garage_model::garage::Garage; -use crate::http_util::*; use crate::signature::check_signature; use crate::s3_copy::*; @@ -50,7 +49,7 @@ async fn handler( garage: Arc, req: Request, addr: SocketAddr, -) -> Result, Error> { +) -> Result, Error> { info!("{} {} {}", addr, req.method(), req.uri()); debug!("{:?}", req); match handler_inner(garage, req).await { @@ -59,7 +58,7 @@ async fn handler( Ok(x) } Err(e) => { - let body: BodyType = Box::new(BytesBody::from(format!("{}\n", e))); + let body: Body = Body::from(format!("{}\n", e)); let mut http_error = Response::new(body); *http_error.status_mut() = e.http_status_code(); warn!("Response: error {}, {}", e.http_status_code(), e); @@ -71,7 +70,7 @@ async fn handler( async fn handler_inner( garage: Arc, req: Request, -) -> Result, Error> { +) -> Result, Error> { let path = req.uri().path().to_string(); let path = percent_encoding::percent_decode_str(&path).decode_utf8()?; @@ -180,7 +179,7 @@ async fn handler_inner( std::str::from_utf8(&hyper::body::to_bytes(req.into_body()).await?) .unwrap_or("") ); - let empty_body: BodyType = Box::new(BytesBody::from(vec![])); + let empty_body: Body = Body::from(vec![]); let response = Response::builder() .header("Location", format!("/{}", bucket)) .body(empty_body) @@ -189,7 +188,7 @@ async fn handler_inner( } &Method::HEAD => { // HeadBucket - let empty_body: BodyType = Box::new(BytesBody::from(vec![])); + let empty_body: Body = Body::from(vec![]); let response = Response::builder().body(empty_body).unwrap(); Ok(response) } -- cgit v1.2.3