@@ -17,6 +17,7 @@ use std::{
1717 time:: { Duration , SystemTime , UNIX_EPOCH } ,
1818} ;
1919
20+ use super :: TryNormalizePath ;
2021use anyhow:: { anyhow, Context } ;
2122use aws_config:: { retry:: RetryConfig , AppName , BehaviorVersion , Region } ;
2223use aws_credential_types:: { credential_fn:: provide_credentials_fn, Credentials } ;
@@ -44,12 +45,9 @@ use futures::{
4445 stream:: FuturesUnordered ,
4546 AsyncWriteExt , FutureExt , StreamExt , TryFutureExt ,
4647} ;
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+
5149use memmap2:: { MmapOptions , MmapRaw } ;
52- use once_cell:: sync:: { Lazy , OnceCell } ;
50+ use once_cell:: sync:: OnceCell ;
5351use serde:: { Deserialize , Serialize } ;
5452use tempfile:: tempfile;
5553use tokio:: {
@@ -58,9 +56,6 @@ use tokio::{
5856 task:: JoinError ,
5957} ;
6058use tracing:: { debug, error, info_span, instrument, trace, trace_span, warn, Instrument } ;
61- use url:: Url ;
62-
63- use super :: TryNormalizePath ;
6459
6560const MIN_PART_SIZE : usize = 1024 * 1024 * 5 ;
6661
@@ -240,9 +235,17 @@ impl S3FsConfig {
240235 CLIENT . with ( |it| {
241236 it. borrow_mut ( )
242237 . 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+ {
246249 HyperClientBuilder :: new ( ) . build_https ( )
247250 }
248251 } )
@@ -251,7 +254,17 @@ impl S3FsConfig {
251254 }
252255}
253256
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+
255268 let proxy_url: Url = std:: env:: var ( "HTTPS_PROXY" ) . ok ( ) ?. parse ( ) . ok ( ) ?;
256269 let proxy_uri: Uri = std:: env:: var ( "HTTPS_PROXY" ) . ok ( ) ?. parse ( ) . ok ( ) ?;
257270 let mut proxy = Proxy :: new ( Intercept :: All , proxy_uri) ;
0 commit comments