Loading crates/s3s/src/http/body.rs +8 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,14 @@ impl Body { } } pub fn take_bytes(&mut self) -> Option<Bytes> { match mem::take(&mut self.kind) { Kind::Empty => Some(Bytes::new()), Kind::Once { inner } => Some(inner), _ => None, } } fn into_hyper(self) -> hyper::Body { match self.kind { Kind::Empty => hyper::Body::empty(), Loading crates/s3s/src/http/de.rs +3 −3 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ pub fn take_xml_body<T>(req: &mut Request) -> S3Result<T> where T: for<'xml> xml::Deserialize<'xml>, { let bytes = req.body.bytes().expect("full body not found"); let bytes = req.body.take_bytes().expect("full body not found"); if bytes.is_empty() { return Err(S3ErrorCode::MissingRequestBodyError.into()); } Loading @@ -179,7 +179,7 @@ pub fn take_opt_xml_body<T>(req: &mut Request) -> S3Result<Option<T>> where T: for<'xml> xml::Deserialize<'xml>, { let bytes = req.body.bytes().expect("full body not found"); let bytes = req.body.take_bytes().expect("full body not found"); if bytes.is_empty() { return Ok(None); } Loading @@ -191,7 +191,7 @@ where } pub fn take_string_body(req: &mut Request) -> S3Result<String> { let bytes = req.body.bytes().expect("full body not found"); let bytes = req.body.take_bytes().expect("full body not found"); match String::from_utf8_simd(bytes.into()) { Some(s) => Ok(s), None => Err(invalid_request!("expected UTF-8 body")), Loading Loading
crates/s3s/src/http/body.rs +8 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,14 @@ impl Body { } } pub fn take_bytes(&mut self) -> Option<Bytes> { match mem::take(&mut self.kind) { Kind::Empty => Some(Bytes::new()), Kind::Once { inner } => Some(inner), _ => None, } } fn into_hyper(self) -> hyper::Body { match self.kind { Kind::Empty => hyper::Body::empty(), Loading
crates/s3s/src/http/de.rs +3 −3 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ pub fn take_xml_body<T>(req: &mut Request) -> S3Result<T> where T: for<'xml> xml::Deserialize<'xml>, { let bytes = req.body.bytes().expect("full body not found"); let bytes = req.body.take_bytes().expect("full body not found"); if bytes.is_empty() { return Err(S3ErrorCode::MissingRequestBodyError.into()); } Loading @@ -179,7 +179,7 @@ pub fn take_opt_xml_body<T>(req: &mut Request) -> S3Result<Option<T>> where T: for<'xml> xml::Deserialize<'xml>, { let bytes = req.body.bytes().expect("full body not found"); let bytes = req.body.take_bytes().expect("full body not found"); if bytes.is_empty() { return Ok(None); } Loading @@ -191,7 +191,7 @@ where } pub fn take_string_body(req: &mut Request) -> S3Result<String> { let bytes = req.body.bytes().expect("full body not found"); let bytes = req.body.take_bytes().expect("full body not found"); match String::from_utf8_simd(bytes.into()) { Some(s) => Ok(s), None => Err(invalid_request!("expected UTF-8 body")), Loading