diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index adc7484a..30dfcaa6 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -81,7 +81,7 @@ macro_rules! test_header { let a: Vec> = raw.iter().map(|x| x.to_vec()).collect(); let mut req = test::TestRequest::default(); for item in a { - req = req.header(HeaderField::name(), item); + req = req.header(HeaderField::name(), item).take(); } let req = req.finish(); let value = HeaderField::parse(&req); @@ -104,11 +104,11 @@ macro_rules! test_header { #[test] fn $id() { use $crate::test; - + let a: Vec> = $raw.iter().map(|x| x.to_vec()).collect(); let mut req = test::TestRequest::default(); for item in a { - req = req.header(HeaderField::name(), item); + req.header(HeaderField::name(), item); } let req = req.finish(); let val = HeaderField::parse(&req); diff --git a/src/response.rs b/src/response.rs index 80748746..9b503de1 100644 --- a/src/response.rs +++ b/src/response.rs @@ -4,6 +4,7 @@ use std::{fmt, str}; use bytes::{BufMut, Bytes, BytesMut}; use cookie::{Cookie, CookieJar}; +use futures::future::{ok, FutureResult, IntoFuture}; use futures::Stream; use http::header::{self, HeaderName, HeaderValue}; use http::{Error as HttpError, HeaderMap, HttpTryFrom, StatusCode}; @@ -276,6 +277,16 @@ impl fmt::Debug for Response { } } +impl IntoFuture for Response { + type Item = Response; + type Error = Error; + type Future = FutureResult; + + fn into_future(self) -> Self::Future { + ok(self) + } +} + pub struct CookieIter<'a> { iter: header::ValueIter<'a, HeaderValue>, } @@ -679,6 +690,16 @@ fn parts<'a>( parts.as_mut() } +impl IntoFuture for ResponseBuilder { + type Item = Response; + type Error = Error; + type Future = FutureResult; + + fn into_future(mut self) -> Self::Future { + ok(self.finish()) + } +} + /// Helper converters impl, E: Into> From> for Response { fn from(res: Result) -> Self {