1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-20 08:31:09 +00:00

Rename HttpRequest::without_state into drop_state and make it public

This commit is contained in:
Douman 2018-04-11 22:27:17 +03:00
parent c570229351
commit 62a9b4c53c
5 changed files with 15 additions and 15 deletions

View file

@ -498,18 +498,18 @@ impl<S: 'static> Handler<S> for StaticFiles<S> {
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())
}
}
}

View file

@ -337,7 +337,7 @@ impl<S, H, R> RouteHandler<S> for WrapHandler<S, H, R>
S: 'static,
{
fn handle(&mut self, req: HttpRequest<S>) -> 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<S, H, F, R, E> RouteHandler<S> for AsyncHandler<S, H, F, R, E>
S: 'static,
{
fn handle(&mut self, req: HttpRequest<S>) -> Reply {
let req2 = req.without_state();
let req2 = req.drop_state();
let fut = (self.h)(req)
.map_err(|e| e.into())
.then(move |r| {

View file

@ -172,7 +172,7 @@ impl<S> HttpRequest<S> {
#[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())
}

View file

@ -559,7 +559,7 @@ impl<S> TestRequest<S> {
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<S> TestRequest<S> {
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"),

View file

@ -134,7 +134,7 @@ impl<T, S, F, R> Future for WithHandlerFut<T, S, F, R>
};
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<T1, T2, S, F, R> Future for WithHandlerFut2<T1, T2, S, F, R>
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<T1, T2, S, F, R> Future for WithHandlerFut2<T1, T2, S, F, R>
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<T1, T2, T3, S, F, R> Future for WithHandlerFut3<T1, T2, T3, S, F, R>
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<T1, T2, T3, S, F, R> Future for WithHandlerFut3<T1, T2, T3, S, F, R>
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()),