@@ -173,11 +173,11 @@ pub fn http_handle(config: &Config) -> CargoResult<http::Handle> {
173
173
Ok ( handle)
174
174
}
175
175
176
- /// Find a globally configured HTTP proxy if one is available.
176
+ /// Find an explicit HTTP proxy if one is available.
177
177
///
178
- /// Favor cargo's `http.proxy`, then git's `http.proxy`, then finally a
179
- /// HTTP_PROXY env var .
180
- pub fn http_proxy ( config : & Config ) -> CargoResult < Option < String > > {
178
+ /// Favor cargo's `http.proxy`, then git's `http.proxy`. Proxies specified
179
+ /// via environment variables are picked up by libcurl .
180
+ fn http_proxy ( config : & Config ) -> CargoResult < Option < String > > {
181
181
match try!( config. get_string ( "http.proxy" ) ) {
182
182
Some ( ( s, _) ) => return Ok ( Some ( s) ) ,
183
183
None => { }
@@ -191,7 +191,26 @@ pub fn http_proxy(config: &Config) -> CargoResult<Option<String>> {
191
191
}
192
192
Err ( ..) => { }
193
193
}
194
- Ok ( env:: var ( "HTTP_PROXY" ) . ok ( ) )
194
+ Ok ( None )
195
+ }
196
+
197
+ /// Determine if an http proxy exists.
198
+ ///
199
+ /// Checks the following for existence, in order:
200
+ ///
201
+ /// * cargo's `http.proxy`
202
+ /// * git's `http.proxy`
203
+ /// * http_proxy env var
204
+ /// * HTTP_PROXY env var
205
+ /// * https_proxy env var
206
+ /// * HTTPS_PROXY env var
207
+ pub fn http_proxy_exists ( config : & Config ) -> CargoResult < bool > {
208
+ if try!( http_proxy ( config) ) . is_some ( ) {
209
+ Ok ( true )
210
+ } else {
211
+ Ok ( [ "http_proxy" , "HTTP_PROXY" ,
212
+ "https_proxy" , "HTTPS_PROXY" ] . iter ( ) . any ( |v| env:: var ( v) . is_ok ( ) ) )
213
+ }
195
214
}
196
215
197
216
pub fn http_timeout ( config : & Config ) -> CargoResult < Option < i64 > > {
0 commit comments