diff --git a/src/wasm/body.rs b/src/wasm/body.rs index d67f510..f261e39 100644 --- a/src/wasm/body.rs +++ b/src/wasm/body.rs @@ -17,7 +17,6 @@ pub struct Body { inner: Inner, } -#[derive(Clone)] enum Inner { Bytes(Bytes), #[cfg(feature = "multipart")] @@ -58,9 +57,13 @@ impl Body { } } - pub(crate) fn clone(&self) -> Body { - Self { - inner: self.inner.clone(), + pub(crate) fn try_clone(&self) -> Option
{ + match &self.inner { + Inner::Bytes(bytes) => Some(Self { + inner: Inner::Bytes(bytes.clone()), + }), + #[cfg(feature = "multipart")] + Inner::Multipart(_) => None, } } } diff --git a/src/wasm/request.rs b/src/wasm/request.rs index 40bb37b..9b36d57 100644 --- a/src/wasm/request.rs +++ b/src/wasm/request.rs @@ -92,14 +92,18 @@ impl Request { /// Attempts to clone the `Request`. /// - /// None is returned if a body is which can not be cloned. This method - /// currently always returns `Some`, but that may change in the future. + /// None is returned if a body is which can not be cloned. pub fn try_clone(&self) -> Option