From 891f126a569e936d2fb201e8af26bf3294615328 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 1 Apr 2021 09:58:13 +0800 Subject: [PATCH] Groupsmigration compiles --- src/mako/api/lib/mbuild.mako | 6 ++++-- src/rust/api/client.rs | 12 +++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mako/api/lib/mbuild.mako b/src/mako/api/lib/mbuild.mako index ac357b8305..80efe9c9ea 100644 --- a/src/mako/api/lib/mbuild.mako +++ b/src/mako/api/lib/mbuild.mako @@ -780,11 +780,13 @@ else { % if simple_media_param: let request = if protocol == "${simple_media_param.protocol}" { ${READER_SEEK | indent_all_but_first_by(4)} + let mut bytes = Vec::with_capacity(size as usize); + reader.read_to_end(&mut bytes)?; req_builder.header(CONTENT_TYPE, reader_mime_type.to_string()) .header(CONTENT_LENGTH, size) - .body(&mut reader); + .body(hyper::body::Body::from(bytes)) } else { - req_builder.body(hyper::body::Body::empty()) + req_builder.body(hyper::body::Body::from(Vec::new())) }\ % else: let request = req_builder diff --git a/src/rust/api/client.rs b/src/rust/api/client.rs index dbf821a6b1..405f6838fb 100644 --- a/src/rust/api/client.rs +++ b/src/rust/api/client.rs @@ -269,11 +269,15 @@ pub enum Error { /// Indicates an HTTP repsonse with a non-success status code Failure(hyper::Response), + + /// An IO error occurred while reading a stream into memory + Io(std::io::Error), } impl Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { + Error::Io(ref err) => err.fmt(f), Error::HttpError(ref err) => err.fmt(f), Error::UploadSizeLimitExceeded(ref resource_size, ref max_size) => writeln!( f, @@ -335,6 +339,12 @@ impl error::Error for Error { } } +impl From for Error { + fn from(err: std::io::Error) -> Self { + Error::Io(err) + } +} + /// A universal result type used as return for all calls. pub type Result = std::result::Result; @@ -593,7 +603,7 @@ impl RangeResponseHeader { } } - panic!(format!("Unable to parse Range header {:?}", raw)) + panic!("Unable to parse Range header {:?}", raw) } }