From 62a9b4c53cd857d9976dbf47b3a08c5256bab29c Mon Sep 17 00:00:00 2001 From: Douman Date: Wed, 11 Apr 2018 22:27:17 +0300 Subject: [PATCH] Rename HttpRequest::without_state into drop_state and make it public --- src/fs.rs | 10 +++++----- src/handler.rs | 4 ++-- src/httprequest.rs | 2 +- src/test.rs | 4 ++-- src/with.rs | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/fs.rs b/src/fs.rs index 73ca68289..495a0510f 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -498,18 +498,18 @@ impl Handler for StaticFiles { HttpResponse::Found() .header(header::LOCATION, new_path.as_str()) .finish() - .respond_to(req.without_state()) + .respond_to(req.drop_state()) } else if self.show_index { Directory::new(self.directory.clone(), path) - .respond_to(req.without_state())? - .respond_to(req.without_state()) + .respond_to(req.drop_state())? + .respond_to(req.drop_state()) } else { Ok(self.default.handle(req)) } } else { NamedFile::open(path)?.set_cpu_pool(self.cpu_pool.clone()) - .respond_to(req.without_state())? - .respond_to(req.without_state()) + .respond_to(req.drop_state())? + .respond_to(req.drop_state()) } } } diff --git a/src/handler.rs b/src/handler.rs index edfd1edbe..1fc7febd7 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -337,7 +337,7 @@ impl RouteHandler for WrapHandler S: 'static, { fn handle(&mut self, req: HttpRequest) -> Reply { - let req2 = req.without_state(); + let req2 = req.drop_state(); match self.h.handle(req).respond_to(req2) { Ok(reply) => reply.into(), Err(err) => Reply::response(err.into()), @@ -378,7 +378,7 @@ impl RouteHandler for AsyncHandler S: 'static, { fn handle(&mut self, req: HttpRequest) -> Reply { - let req2 = req.without_state(); + let req2 = req.drop_state(); let fut = (self.h)(req) .map_err(|e| e.into()) .then(move |r| { diff --git a/src/httprequest.rs b/src/httprequest.rs index 9d8c39b42..b4707f901 100644 --- a/src/httprequest.rs +++ b/src/httprequest.rs @@ -172,7 +172,7 @@ impl HttpRequest { #[inline] /// Construct new http request without state. - pub(crate) fn without_state(&self) -> HttpRequest { + pub fn drop_state(&self) -> HttpRequest { HttpRequest(self.0.clone(), None, self.2.clone()) } diff --git a/src/test.rs b/src/test.rs index 4e5ed9bd0..2a12657c5 100644 --- a/src/test.rs +++ b/src/test.rs @@ -559,7 +559,7 @@ impl TestRequest { let req = self.finish(); let resp = h.handle(req.clone()); - match resp.respond_to(req.without_state()) { + match resp.respond_to(req.drop_state()) { Ok(resp) => { match resp.into().into() { ReplyItem::Message(resp) => Ok(resp), @@ -586,7 +586,7 @@ impl TestRequest { let mut core = Core::new().unwrap(); match core.run(fut) { Ok(r) => { - match r.respond_to(req.without_state()) { + match r.respond_to(req.drop_state()) { Ok(reply) => match reply.into().into() { ReplyItem::Message(resp) => Ok(resp), _ => panic!("Nested async replies are not supported"), diff --git a/src/with.rs b/src/with.rs index 5f70db259..5e117225f 100644 --- a/src/with.rs +++ b/src/with.rs @@ -134,7 +134,7 @@ impl Future for WithHandlerFut }; let hnd: &mut F = unsafe{&mut *self.hnd.get()}; - let item = match (*hnd)(item).respond_to(self.req.without_state()) { + let item = match (*hnd)(item).respond_to(self.req.drop_state()) { Ok(item) => item.into(), Err(e) => return Err(e.into()), }; @@ -241,7 +241,7 @@ impl Future for WithHandlerFut2 Ok(Async::Ready(item2)) => { let hnd: &mut F = unsafe{&mut *self.hnd.get()}; match (*hnd)(item1, item2) - .respond_to(self.req.without_state()) + .respond_to(self.req.drop_state()) { Ok(item) => match item.into().into() { ReplyItem::Message(resp) => @@ -289,7 +289,7 @@ impl Future for WithHandlerFut2 let hnd: &mut F = unsafe{&mut *self.hnd.get()}; let item = match (*hnd)(self.item.take().unwrap(), item) - .respond_to(self.req.without_state()) + .respond_to(self.req.drop_state()) { Ok(item) => item.into(), Err(err) => return Err(err.into()), @@ -417,7 +417,7 @@ impl Future for WithHandlerFut3 Ok(Async::Ready(item3)) => { let hnd: &mut F = unsafe{&mut *self.hnd.get()}; match (*hnd)(item1, item2, item3) - .respond_to(self.req.without_state()) + .respond_to(self.req.drop_state()) { Ok(item) => match item.into().into() { ReplyItem::Message(resp) => @@ -488,7 +488,7 @@ impl Future for WithHandlerFut3 let item = match (*hnd)(self.item1.take().unwrap(), self.item2.take().unwrap(), item) - .respond_to(self.req.without_state()) + .respond_to(self.req.drop_state()) { Ok(item) => item.into(), Err(err) => return Err(err.into()),