mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
update client connector
This commit is contained in:
parent
3a24a75d13
commit
d2c755bb47
@ -61,8 +61,8 @@ impl Address for Connect {
|
|||||||
&self.uri.host().unwrap()
|
&self.uri.host().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn port(&self) -> u16 {
|
fn port(&self) -> Option<u16> {
|
||||||
if let Some(port) = self.uri.port() {
|
let port = if let Some(port) = self.uri.port() {
|
||||||
port
|
port
|
||||||
} else if let Some(scheme) = self.uri.scheme_part() {
|
} else if let Some(scheme) = self.uri.scheme_part() {
|
||||||
match scheme.as_str() {
|
match scheme.as_str() {
|
||||||
@ -72,6 +72,7 @@ impl Address for Connect {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
80
|
80
|
||||||
}
|
};
|
||||||
|
Some(port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ where
|
|||||||
let connector = TimeoutService::new(
|
let connector = TimeoutService::new(
|
||||||
self.timeout,
|
self.timeout,
|
||||||
apply_fn(self.connector, |msg: Connect, srv| {
|
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)),
|
.map(|stream| (stream.into_parts().0, Protocol::Http1)),
|
||||||
)
|
)
|
||||||
@ -200,7 +200,7 @@ where
|
|||||||
let ssl_service = TimeoutService::new(
|
let ssl_service = TimeoutService::new(
|
||||||
self.timeout,
|
self.timeout,
|
||||||
apply_fn(self.connector.clone(), |msg: Connect, srv| {
|
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_err(ConnectError::from)
|
||||||
.and_then(
|
.and_then(
|
||||||
@ -230,7 +230,7 @@ where
|
|||||||
let tcp_service = TimeoutService::new(
|
let tcp_service = TimeoutService::new(
|
||||||
self.timeout,
|
self.timeout,
|
||||||
apply_fn(self.connector.clone(), |msg: Connect, srv| {
|
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_err(ConnectError::from)
|
||||||
.map(|stream| (stream.into_parts().0, Protocol::Http1)),
|
.map(|stream| (stream.into_parts().0, Protocol::Http1)),
|
||||||
|
@ -29,7 +29,7 @@ impl Client<()> {
|
|||||||
/// Create client with default connector.
|
/// Create client with default connector.
|
||||||
pub fn default() -> Client<
|
pub fn default() -> Client<
|
||||||
impl Service<
|
impl Service<
|
||||||
Request = TcpConnect<(String, u16)>,
|
Request = TcpConnect<String>,
|
||||||
Response = impl AsyncRead + AsyncWrite,
|
Response = impl AsyncRead + AsyncWrite,
|
||||||
Error = ConnectError,
|
Error = ConnectError,
|
||||||
> + Clone,
|
> + Clone,
|
||||||
@ -42,7 +42,7 @@ impl Client<()> {
|
|||||||
|
|
||||||
impl<T> Client<T>
|
impl<T> Client<T>
|
||||||
where
|
where
|
||||||
T: Service<Request = TcpConnect<(String, u16)>, Error = ConnectError>,
|
T: Service<Request = TcpConnect<String>, Error = ConnectError>,
|
||||||
T::Response: AsyncRead + AsyncWrite,
|
T::Response: AsyncRead + AsyncWrite,
|
||||||
{
|
{
|
||||||
/// Create new websocket's client factory
|
/// Create new websocket's client factory
|
||||||
@ -53,7 +53,7 @@ where
|
|||||||
|
|
||||||
impl<T> Clone for Client<T>
|
impl<T> Clone for Client<T>
|
||||||
where
|
where
|
||||||
T: Service<Request = TcpConnect<(String, u16)>, Error = ConnectError> + Clone,
|
T: Service<Request = TcpConnect<String>, Error = ConnectError> + Clone,
|
||||||
T::Response: AsyncRead + AsyncWrite,
|
T::Response: AsyncRead + AsyncWrite,
|
||||||
{
|
{
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
@ -65,7 +65,7 @@ where
|
|||||||
|
|
||||||
impl<T> Service for Client<T>
|
impl<T> Service for Client<T>
|
||||||
where
|
where
|
||||||
T: Service<Request = TcpConnect<(String, u16)>, Error = ConnectError>,
|
T: Service<Request = TcpConnect<String>, Error = ConnectError>,
|
||||||
T::Response: AsyncRead + AsyncWrite + 'static,
|
T::Response: AsyncRead + AsyncWrite + 'static,
|
||||||
T::Future: 'static,
|
T::Future: 'static,
|
||||||
{
|
{
|
||||||
@ -130,10 +130,8 @@ where
|
|||||||
);
|
);
|
||||||
|
|
||||||
// prep connection
|
// prep connection
|
||||||
let connect = TcpConnect::from_string(
|
let connect = TcpConnect::new(request.uri().host().unwrap().to_string())
|
||||||
request.uri().host().unwrap().to_string(),
|
.set_port(request.uri().port().unwrap_or_else(|| proto.port()));
|
||||||
request.uri().port().unwrap_or_else(|| proto.port()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let fut = Box::new(
|
let fut = Box::new(
|
||||||
self.connector
|
self.connector
|
||||||
|
Loading…
Reference in New Issue
Block a user