@@ -68,10 +68,10 @@ use url::ParseError as UrlError;
6868use header:: { Headers , Header , HeaderFormat } ;
6969use header:: { ContentLength , Host , Location } ;
7070use method:: Method ;
71- use net:: { NetworkConnector , NetworkStream } ;
71+ use net:: { HttpConnector , NetworkConnector , NetworkStream , SslClient } ;
7272use Error ;
7373
74- use self :: proxy:: tunnel;
74+ use self :: proxy:: { Proxy , tunnel} ;
7575pub use self :: pool:: Pool ;
7676pub use self :: request:: Request ;
7777pub use self :: response:: Response ;
@@ -84,6 +84,11 @@ pub mod response;
8484use http:: Protocol ;
8585use http:: h1:: Http11Protocol ;
8686
87+ /// Proxy server configuration with a custom TLS wrapper.
88+ pub struct ProxyConfig < H , S > ( pub H , pub u16 , pub S )
89+ where H : Into < Cow < ' static , str > > ,
90+ S : SslClient < <HttpConnector as NetworkConnector >:: Stream > + Send + Sync + ' static ;
91+
8792/// A Client to use additional features with Requests.
8893///
8994/// Clients can handle things such as: redirect policy, connection pooling.
@@ -127,6 +132,21 @@ impl Client {
127132 client
128133 }
129134
135+ pub fn with_proxy_config < H , S > ( proxy_config : ProxyConfig < H , S > ) -> Client
136+ where H : Into < Cow < ' static , str > > ,
137+ S : SslClient < <HttpConnector as NetworkConnector >:: Stream > + Send + Sync + ' static {
138+ let host = proxy_config. 0 . into ( ) ;
139+ let port = proxy_config. 1 ;
140+ let proxy = Proxy {
141+ connector : HttpConnector ,
142+ proxy : ( host. clone ( ) , port) ,
143+ ssl : proxy_config. 2
144+ } ;
145+ let mut client = Client :: with_connector ( Pool :: with_connector ( Default :: default ( ) , proxy) ) ;
146+ client. proxy = Some ( ( host, port) ) ;
147+ client
148+ }
149+
130150 /// Create a new client with a specific connector.
131151 pub fn with_connector < C , S > ( connector : C ) -> Client
132152 where C : NetworkConnector < Stream =S > + Send + Sync + ' static , S : NetworkStream + Send {
0 commit comments