@@ -68,10 +68,10 @@ use url::ParseError as UrlError;
68
68
use header:: { Headers , Header , HeaderFormat } ;
69
69
use header:: { ContentLength , Host , Location } ;
70
70
use method:: Method ;
71
- use net:: { NetworkConnector , NetworkStream } ;
71
+ use net:: { HttpConnector , NetworkConnector , NetworkStream , SslClient } ;
72
72
use Error ;
73
73
74
- use self :: proxy:: tunnel;
74
+ use self :: proxy:: { Proxy , tunnel} ;
75
75
pub use self :: pool:: Pool ;
76
76
pub use self :: request:: Request ;
77
77
pub use self :: response:: Response ;
@@ -84,6 +84,11 @@ pub mod response;
84
84
use http:: Protocol ;
85
85
use http:: h1:: Http11Protocol ;
86
86
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
+
87
92
/// A Client to use additional features with Requests.
88
93
///
89
94
/// Clients can handle things such as: redirect policy, connection pooling.
@@ -127,6 +132,21 @@ impl Client {
127
132
client
128
133
}
129
134
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
+
130
150
/// Create a new client with a specific connector.
131
151
pub fn with_connector < C , S > ( connector : C ) -> Client
132
152
where C : NetworkConnector < Stream =S > + Send + Sync + ' static , S : NetworkStream + Send {
0 commit comments