File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ cfg( feature = "reqwest-backend" ) ]
2
+
3
+ use std:: env:: { remove_var, set_var} ;
4
+
5
+ use env_proxy:: for_url;
6
+ use url:: Url ;
7
+
8
+ fn scrub_env ( ) {
9
+ remove_var ( "http_proxy" ) ;
10
+ remove_var ( "https_proxy" ) ;
11
+ remove_var ( "HTTPS_PROXY" ) ;
12
+ remove_var ( "ftp_proxy" ) ;
13
+ remove_var ( "FTP_PROXY" ) ;
14
+ remove_var ( "all_proxy" ) ;
15
+ remove_var ( "ALL_PROXY" ) ;
16
+ remove_var ( "no_proxy" ) ;
17
+ remove_var ( "NO_PROXY" ) ;
18
+ }
19
+
20
+ // Tests for correctly retrieving the proxy (host, port) tuple from $https_proxy
21
+ #[ test]
22
+ fn read_basic_proxy_params ( ) {
23
+ scrub_env ( ) ;
24
+ set_var ( "https_proxy" , "http://proxy.example.com:8080" ) ;
25
+ let u = Url :: parse ( "https://www.example.org" ) . ok ( ) . unwrap ( ) ;
26
+ assert_eq ! (
27
+ for_url( & u) . host_port( ) ,
28
+ Some ( ( "proxy.example.com" . to_string( ) , 8080 ) )
29
+ ) ;
30
+ }
You can’t perform that action at this time.
0 commit comments