diff --git a/src/httprequest.rs b/src/httprequest.rs index 56e95e9e..08de0a8f 100644 --- a/src/httprequest.rs +++ b/src/httprequest.rs @@ -74,7 +74,7 @@ impl HttpRequest { pub(crate) fn with_state(&self, state: Rc) -> HttpRequest { HttpRequest { state, - req: self.req.clone(), + req: self.req.as_ref().map(|r| r.clone()), route: self.route.clone(), } } @@ -84,7 +84,7 @@ impl HttpRequest { pub(crate) fn with_route_info(&self, route: RouteInfo) -> HttpRequest { HttpRequest { route, - req: self.req.clone(), + req: self.req.as_ref().map(|r| r.clone()), state: self.state.clone(), } } @@ -327,7 +327,7 @@ impl Drop for HttpRequest { impl Clone for HttpRequest { fn clone(&self) -> HttpRequest { HttpRequest { - req: self.req.clone(), + req: self.req.as_ref().map(|r| r.clone()), state: self.state.clone(), route: self.route.clone(), } diff --git a/src/server/message.rs b/src/server/message.rs index eb1395ac..395d7b7c 100644 --- a/src/server/message.rs +++ b/src/server/message.rs @@ -20,7 +20,6 @@ bitflags! { } /// Request's context -#[derive(Clone)] pub struct Request { pub(crate) inner: Rc, } @@ -196,6 +195,12 @@ impl Request { &self.inner().settings } + pub(crate) fn clone(&self) -> Self { + Request { + inner: self.inner.clone(), + } + } + pub(crate) fn release(self) { let mut inner = self.inner; if let Some(r) = Rc::get_mut(&mut inner) {