| @@ -15,8 +15,8 @@ use futures::{Async, Future, Poll}; | ||||
| use futures::future::{self, Either}; | ||||
| use tokio_io::{AsyncRead, AsyncWrite}; | ||||
|  | ||||
| use body::Payload; | ||||
| use proto; | ||||
| use proto::body::Entity; | ||||
| use super::dispatch; | ||||
| use {Body, Request, Response, StatusCode}; | ||||
|  | ||||
| @@ -45,7 +45,7 @@ pub struct SendRequest<B> { | ||||
| pub struct Connection<T, B> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
| { | ||||
|     inner: proto::dispatch::Dispatcher< | ||||
|         proto::dispatch::Client<B>, | ||||
| @@ -138,7 +138,7 @@ impl<B> SendRequest<B> | ||||
|  | ||||
| impl<B> SendRequest<B> | ||||
| where | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
| { | ||||
|     /// Sends a `Request` on the associated connection. | ||||
|     /// | ||||
| @@ -262,7 +262,7 @@ impl<B> fmt::Debug for SendRequest<B> { | ||||
| impl<T, B> Connection<T, B> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
| { | ||||
|     /// Return the inner IO object, and additional information. | ||||
|     pub fn into_parts(self) -> Parts<T> { | ||||
| @@ -289,7 +289,7 @@ where | ||||
| impl<T, B> Future for Connection<T, B> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
| { | ||||
|     type Item = (); | ||||
|     type Error = ::Error; | ||||
| @@ -302,7 +302,7 @@ where | ||||
| impl<T, B> fmt::Debug for Connection<T, B> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite + fmt::Debug, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
| { | ||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||
|         f.debug_struct("Connection") | ||||
| @@ -331,7 +331,7 @@ impl Builder { | ||||
|     pub fn handshake<T, B>(&self, io: T) -> Handshake<T, B> | ||||
|     where | ||||
|         T: AsyncRead + AsyncWrite, | ||||
|         B: Entity + 'static, | ||||
|         B: Payload + 'static, | ||||
|     { | ||||
|         Handshake { | ||||
|             inner: HandshakeInner { | ||||
| @@ -345,7 +345,7 @@ impl Builder { | ||||
|     pub(super) fn handshake_no_upgrades<T, B>(&self, io: T) -> HandshakeNoUpgrades<T, B> | ||||
|     where | ||||
|         T: AsyncRead + AsyncWrite, | ||||
|         B: Entity + 'static, | ||||
|         B: Payload + 'static, | ||||
|     { | ||||
|         HandshakeNoUpgrades { | ||||
|             inner: HandshakeInner { | ||||
| @@ -362,7 +362,7 @@ impl Builder { | ||||
| impl<T, B> Future for Handshake<T, B> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
| { | ||||
|     type Item = (SendRequest<B>, Connection<T, B>); | ||||
|     type Error = ::Error; | ||||
| @@ -387,7 +387,7 @@ impl<T, B> fmt::Debug for Handshake<T, B> { | ||||
| impl<T, B> Future for HandshakeNoUpgrades<T, B> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
| { | ||||
|     type Item = (SendRequest<B>, proto::dispatch::Dispatcher< | ||||
|         proto::dispatch::Client<B>, | ||||
| @@ -406,7 +406,7 @@ where | ||||
| impl<T, B, R> Future for HandshakeInner<T, B, R> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
|     R: proto::Http1Transaction< | ||||
|         Incoming=StatusCode, | ||||
|         Outgoing=proto::RequestLine, | ||||
| @@ -470,7 +470,7 @@ impl<B: Send> AssertSendSync for SendRequest<B> {} | ||||
| impl<T: Send, B: Send> AssertSend for Connection<T, B> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
|     B::Data: Send + 'static, | ||||
| {} | ||||
|  | ||||
| @@ -478,7 +478,7 @@ where | ||||
| impl<T: Send + Sync, B: Send + Sync> AssertSendSync for Connection<T, B> | ||||
| where | ||||
|     T: AsyncRead + AsyncWrite, | ||||
|     B: Entity + 'static, | ||||
|     B: Payload + 'static, | ||||
|     B::Data: Send + Sync + 'static, | ||||
| {} | ||||
|  | ||||
|   | ||||
| @@ -16,8 +16,7 @@ use tokio::reactor::Handle; | ||||
| use tokio_executor::spawn; | ||||
| pub use tokio_service::Service; | ||||
|  | ||||
| use proto::body::{Body, Entity}; | ||||
| use proto; | ||||
| use body::{Body, Payload}; | ||||
| use self::pool::Pool; | ||||
|  | ||||
| pub use self::connect::{Connect, HttpConnector}; | ||||
| @@ -34,7 +33,7 @@ mod pool; | ||||
| mod tests; | ||||
|  | ||||
| /// A Client to make outgoing HTTP requests. | ||||
| pub struct Client<C, B = proto::Body> { | ||||
| pub struct Client<C, B = Body> { | ||||
|     connector: Arc<C>, | ||||
|     executor: Exec, | ||||
|     h1_writev: bool, | ||||
| @@ -43,21 +42,21 @@ pub struct Client<C, B = proto::Body> { | ||||
|     set_host: bool, | ||||
| } | ||||
|  | ||||
| impl Client<HttpConnector, proto::Body> { | ||||
| impl Client<HttpConnector, Body> { | ||||
|     /// Create a new Client with the default config. | ||||
|     #[inline] | ||||
|     pub fn new(handle: &Handle) -> Client<HttpConnector, proto::Body> { | ||||
|     pub fn new(handle: &Handle) -> Client<HttpConnector, Body> { | ||||
|         Config::default().build(handle) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Default for Client<HttpConnector, proto::Body> { | ||||
|     fn default() -> Client<HttpConnector, proto::Body> { | ||||
| impl Default for Client<HttpConnector, Body> { | ||||
|     fn default() -> Client<HttpConnector, Body> { | ||||
|         Client::new(&Handle::current()) | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Client<HttpConnector, proto::Body> { | ||||
| impl Client<HttpConnector, Body> { | ||||
|     /// Configure a Client. | ||||
|     /// | ||||
|     /// # Example | ||||
| @@ -76,7 +75,7 @@ impl Client<HttpConnector, proto::Body> { | ||||
|     /// # } | ||||
|     /// ``` | ||||
|     #[inline] | ||||
|     pub fn configure() -> Config<UseDefaultConnector, proto::Body> { | ||||
|     pub fn configure() -> Config<UseDefaultConnector, Body> { | ||||
|         Config::default() | ||||
|     } | ||||
| } | ||||
| @@ -99,7 +98,7 @@ impl<C, B> Client<C, B> | ||||
| where C: Connect + Sync + 'static, | ||||
|       C::Transport: 'static, | ||||
|       C::Future: 'static, | ||||
|       B: Entity + Send + 'static, | ||||
|       B: Payload + Send + 'static, | ||||
|       B::Data: Send, | ||||
| { | ||||
|  | ||||
| @@ -107,16 +106,16 @@ where C: Connect + Sync + 'static, | ||||
|     /// | ||||
|     /// # Note | ||||
|     /// | ||||
|     /// This requires that the `Entity` type have a `Default` implementation. | ||||
|     /// This requires that the `Payload` type have a `Default` implementation. | ||||
|     /// It *should* return an "empty" version of itself, such that | ||||
|     /// `Entity::is_end_stream` is `true`. | ||||
|     /// `Payload::is_end_stream` is `true`. | ||||
|     pub fn get(&self, uri: Uri) -> FutureResponse | ||||
|     where | ||||
|         B: Default, | ||||
|     { | ||||
|         let body = B::default(); | ||||
|         if !body.is_end_stream() { | ||||
|             warn!("default Entity used for get() does not return true for is_end_stream"); | ||||
|             warn!("default Payload used for get() does not return true for is_end_stream"); | ||||
|         } | ||||
|  | ||||
|         let mut req = Request::new(body); | ||||
| @@ -291,7 +290,7 @@ where C: Connect + Sync + 'static, | ||||
| impl<C, B> Service for Client<C, B> | ||||
| where C: Connect + 'static, | ||||
|       C::Future: 'static, | ||||
|       B: Entity + Send + 'static, | ||||
|       B: Payload + Send + 'static, | ||||
|       B::Data: Send, | ||||
| { | ||||
|     type Request = Request<B>; | ||||
| @@ -354,7 +353,7 @@ impl<C, B> Future for RetryableSendRequest<C, B> | ||||
| where | ||||
|     C: Connect + 'static, | ||||
|     C::Future: 'static, | ||||
|     B: Entity + Send + 'static, | ||||
|     B: Payload + Send + 'static, | ||||
|     B::Data: Send, | ||||
| { | ||||
|     type Item = Response<Body>; | ||||
| @@ -444,10 +443,10 @@ pub struct Config<C, B> { | ||||
| #[derive(Debug, Clone, Copy)] | ||||
| pub struct UseDefaultConnector(()); | ||||
|  | ||||
| impl Default for Config<UseDefaultConnector, proto::Body> { | ||||
|     fn default() -> Config<UseDefaultConnector, proto::Body> { | ||||
| impl Default for Config<UseDefaultConnector, Body> { | ||||
|     fn default() -> Config<UseDefaultConnector, Body> { | ||||
|         Config { | ||||
|             _body_type: PhantomData::<proto::Body>, | ||||
|             _body_type: PhantomData::<Body>, | ||||
|             connector: UseDefaultConnector(()), | ||||
|             keep_alive: true, | ||||
|             keep_alive_timeout: Some(Duration::from_secs(90)), | ||||
| @@ -566,7 +565,7 @@ impl<C, B> Config<C, B> | ||||
| where C: Connect, | ||||
|       C::Transport: 'static, | ||||
|       C::Future: 'static, | ||||
|       B: Entity + Send, | ||||
|       B: Payload + Send, | ||||
|       B::Data: Send, | ||||
| { | ||||
|     /// Construct the Client with this configuration. | ||||
| @@ -589,7 +588,7 @@ where C: Connect, | ||||
|  | ||||
| impl<B> Config<UseDefaultConnector, B> | ||||
| where | ||||
|     B: Entity + Send, | ||||
|     B: Payload + Send, | ||||
|     B::Data: Send, | ||||
| { | ||||
|     /// Construct the Client with this configuration. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user