1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 00:50:20 +02:00

refactor actix_http connection types and connector services (#2081)

This commit is contained in:
fakeshadow
2021-03-18 10:53:22 -07:00
committed by GitHub
parent abcb444dd9
commit b75b5114c3
16 changed files with 867 additions and 611 deletions

View File

@@ -6,7 +6,7 @@ use std::time::Duration;
use actix_codec::{AsyncRead, AsyncWrite};
use actix_http::{
client::{Connector, TcpConnect, TcpConnectError, TcpConnection},
client::{Connector, ConnectorService, TcpConnect, TcpConnectError, TcpConnection},
http::{self, header, Error as HttpError, HeaderMap, HeaderName, Uri},
};
use actix_rt::net::TcpStream;
@@ -15,7 +15,7 @@ use actix_service::{boxed, Service};
use crate::connect::DefaultConnector;
use crate::error::SendRequestError;
use crate::middleware::{NestTransform, Redirect, Transform};
use crate::{Client, ClientConfig, ConnectRequest, ConnectResponse, ConnectorService};
use crate::{Client, ClientConfig, ConnectRequest, ConnectResponse};
/// An HTTP Client builder
///
@@ -234,7 +234,7 @@ where
/// Finish build process and create `Client` instance.
pub fn finish(self) -> Client
where
M: Transform<ConnectorService, ConnectRequest> + 'static,
M: Transform<DefaultConnector<ConnectorService<S, Io>>, ConnectRequest> + 'static,
M::Transform:
Service<ConnectRequest, Response = ConnectResponse, Error = SendRequestError>,
{
@@ -250,7 +250,7 @@ where
fn _finish(self) -> Client
where
M: Transform<ConnectorService, ConnectRequest> + 'static,
M: Transform<DefaultConnector<ConnectorService<S, Io>>, ConnectRequest> + 'static,
M::Transform:
Service<ConnectRequest, Response = ConnectResponse, Error = SendRequestError>,
{
@@ -269,16 +269,14 @@ where
connector = connector.local_address(val);
}
let connector = boxed::service(DefaultConnector::new(connector.finish()));
let connector = boxed::service(self.middleware.new_transform(connector));
let connector = DefaultConnector::new(connector.finish());
let connector = boxed::rc_service(self.middleware.new_transform(connector));
let config = ClientConfig {
headers: self.headers,
Client(ClientConfig {
headers: Rc::new(self.headers),
timeout: self.timeout,
connector,
};
Client(Rc::new(config))
})
}
}