@@ -17,6 +17,7 @@ use std::{
17
17
time:: { Duration , SystemTime , UNIX_EPOCH } ,
18
18
} ;
19
19
20
+ use super :: TryNormalizePath ;
20
21
use anyhow:: { anyhow, Context } ;
21
22
use aws_config:: { retry:: RetryConfig , AppName , BehaviorVersion , Region } ;
22
23
use aws_credential_types:: { credential_fn:: provide_credentials_fn, Credentials } ;
@@ -44,12 +45,9 @@ use futures::{
44
45
stream:: FuturesUnordered ,
45
46
AsyncWriteExt , FutureExt , StreamExt , TryFutureExt ,
46
47
} ;
47
- use headers:: Authorization ;
48
- use hyper_proxy:: { Intercept , Proxy , ProxyConnector } ;
49
- use hyper_rustls:: { HttpsConnector , HttpsConnectorBuilder } ;
50
- use hyper_v014:: { client:: HttpConnector , Uri } ;
48
+
51
49
use memmap2:: { MmapOptions , MmapRaw } ;
52
- use once_cell:: sync:: { Lazy , OnceCell } ;
50
+ use once_cell:: sync:: OnceCell ;
53
51
use serde:: { Deserialize , Serialize } ;
54
52
use tempfile:: tempfile;
55
53
use tokio:: {
@@ -58,9 +56,6 @@ use tokio::{
58
56
task:: JoinError ,
59
57
} ;
60
58
use tracing:: { debug, error, info_span, instrument, trace, trace_span, warn, Instrument } ;
61
- use url:: Url ;
62
-
63
- use super :: TryNormalizePath ;
64
59
65
60
const MIN_PART_SIZE : usize = 1024 * 1024 * 5 ;
66
61
@@ -240,9 +235,17 @@ impl S3FsConfig {
240
235
CLIENT . with ( |it| {
241
236
it. borrow_mut ( )
242
237
. get_or_init ( || {
243
- if let Some ( proxy_connector) = resolve_proxy_connector ( ) {
244
- HyperClientBuilder :: new ( ) . build ( proxy_connector)
245
- } else {
238
+ #[ cfg( feature = "unsafe-proxy" ) ]
239
+ {
240
+ if let Some ( proxy_connector) = resolve_proxy_connector ( ) {
241
+ HyperClientBuilder :: new ( ) . build ( proxy_connector)
242
+ } else {
243
+ HyperClientBuilder :: new ( ) . build_https ( )
244
+ }
245
+ }
246
+
247
+ #[ cfg( not( feature = "unsafe-proxy" ) ) ]
248
+ {
246
249
HyperClientBuilder :: new ( ) . build_https ( )
247
250
}
248
251
} )
@@ -251,7 +254,17 @@ impl S3FsConfig {
251
254
}
252
255
}
253
256
254
- fn resolve_proxy_connector ( ) -> Option < ProxyConnector < HttpsConnector < HttpConnector > > > {
257
+ #[ cfg( feature = "unsafe-proxy" ) ]
258
+ fn resolve_proxy_connector ( ) -> Option <
259
+ hyper_proxy:: ProxyConnector < hyper_rustls:: HttpsConnector < hyper_v014:: client:: HttpConnector > > ,
260
+ > {
261
+ use headers:: Authorization ;
262
+ use hyper_proxy:: { Intercept , Proxy , ProxyConnector } ;
263
+ use hyper_rustls:: { HttpsConnector , HttpsConnectorBuilder } ;
264
+ use hyper_v014:: { client:: HttpConnector , Uri } ;
265
+ use once_cell:: sync:: Lazy ;
266
+ use url:: Url ;
267
+
255
268
let proxy_url: Url = std:: env:: var ( "HTTPS_PROXY" ) . ok ( ) ?. parse ( ) . ok ( ) ?;
256
269
let proxy_uri: Uri = std:: env:: var ( "HTTPS_PROXY" ) . ok ( ) ?. parse ( ) . ok ( ) ?;
257
270
let mut proxy = Proxy :: new ( Intercept :: All , proxy_uri) ;
0 commit comments