From d2c755bb47907f35e5883507b0a56cb23e4f4bf5 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 13 Mar 2019 22:57:28 -0700 Subject: [PATCH] update client connector --- src/client/connect.rs | 7 ++++--- src/client/connector.rs | 6 +++--- src/ws/client/service.rs | 14 ++++++-------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/client/connect.rs b/src/client/connect.rs index 93626b0a..82e5e45c 100644 --- a/src/client/connect.rs +++ b/src/client/connect.rs @@ -61,8 +61,8 @@ impl Address for Connect { &self.uri.host().unwrap() } - fn port(&self) -> u16 { - if let Some(port) = self.uri.port() { + fn port(&self) -> Option { + let port = if let Some(port) = self.uri.port() { port } else if let Some(scheme) = self.uri.scheme_part() { match scheme.as_str() { @@ -72,6 +72,7 @@ impl Address for Connect { } } else { 80 - } + }; + Some(port) } } diff --git a/src/client/connector.rs b/src/client/connector.rs index b8b583a9..c764b93c 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -173,7 +173,7 @@ where let connector = TimeoutService::new( self.timeout, apply_fn(self.connector, |msg: Connect, srv| { - srv.call(actix_connect::Connect::with(msg)) + srv.call(actix_connect::Connect::new(msg)) }) .map(|stream| (stream.into_parts().0, Protocol::Http1)), ) @@ -200,7 +200,7 @@ where let ssl_service = TimeoutService::new( self.timeout, apply_fn(self.connector.clone(), |msg: Connect, srv| { - srv.call(actix_connect::Connect::with(msg)) + srv.call(actix_connect::Connect::new(msg)) }) .map_err(ConnectError::from) .and_then( @@ -230,7 +230,7 @@ where let tcp_service = TimeoutService::new( self.timeout, apply_fn(self.connector.clone(), |msg: Connect, srv| { - srv.call(actix_connect::Connect::with(msg)) + srv.call(actix_connect::Connect::new(msg)) }) .map_err(ConnectError::from) .map(|stream| (stream.into_parts().0, Protocol::Http1)), diff --git a/src/ws/client/service.rs b/src/ws/client/service.rs index 7be30993..1aa39124 100644 --- a/src/ws/client/service.rs +++ b/src/ws/client/service.rs @@ -29,7 +29,7 @@ impl Client<()> { /// Create client with default connector. pub fn default() -> Client< impl Service< - Request = TcpConnect<(String, u16)>, + Request = TcpConnect, Response = impl AsyncRead + AsyncWrite, Error = ConnectError, > + Clone, @@ -42,7 +42,7 @@ impl Client<()> { impl Client where - T: Service, Error = ConnectError>, + T: Service, Error = ConnectError>, T::Response: AsyncRead + AsyncWrite, { /// Create new websocket's client factory @@ -53,7 +53,7 @@ where impl Clone for Client where - T: Service, Error = ConnectError> + Clone, + T: Service, Error = ConnectError> + Clone, T::Response: AsyncRead + AsyncWrite, { fn clone(&self) -> Self { @@ -65,7 +65,7 @@ where impl Service for Client where - T: Service, Error = ConnectError>, + T: Service, Error = ConnectError>, T::Response: AsyncRead + AsyncWrite + 'static, T::Future: 'static, { @@ -130,10 +130,8 @@ where ); // prep connection - let connect = TcpConnect::from_string( - request.uri().host().unwrap().to_string(), - request.uri().port().unwrap_or_else(|| proto.port()), - ); + let connect = TcpConnect::new(request.uri().host().unwrap().to_string()) + .set_port(request.uri().port().unwrap_or_else(|| proto.port())); let fut = Box::new( self.connector