1- #[ cfg( not( target_os = "windows" ) ) ]
2- use std:: borrow:: Cow ;
3- #[ cfg( target_os = "windows" ) ]
4- use std:: time:: Duration ;
51use std:: {
62 collections:: HashMap ,
73 io,
@@ -30,13 +26,6 @@ use hyper::{
3026} ;
3127use once_cell:: sync:: Lazy ;
3228use proxy_protocol:: ProxyHeader ;
33- #[ cfg( feature = "hyper" ) ]
34- #[ cfg( target_os = "windows" ) ]
35- use tokio:: net:: windows:: named_pipe:: ClientOptions ;
36- #[ cfg( not( target_os = "windows" ) ) ]
37- use tokio:: net:: UnixStream ;
38- #[ cfg( target_os = "windows" ) ]
39- use tokio:: time;
4029use tokio:: {
4130 io:: copy_bidirectional,
4231 net:: TcpStream ,
@@ -55,8 +44,6 @@ use tracing::{
5544 Span ,
5645} ;
5746use url:: Url ;
58- #[ cfg( target_os = "windows" ) ]
59- use windows_sys:: Win32 :: Foundation :: ERROR_PIPE_BUSY ;
6047
6148use crate :: {
6249 prelude:: * ,
@@ -315,7 +302,10 @@ async fn connect(
315302
316303 #[ cfg( not( target_os = "windows" ) ) ]
317304 "unix" => {
318- //
305+ use std:: borrow:: Cow ;
306+
307+ use tokio:: net:: UnixStream ;
308+
319309 let mut addr = Cow :: Borrowed ( url. path ( ) ) ;
320310 if let Some ( host) = url. host_str ( ) {
321311 // note: if host exists, there should always be a leading / in
@@ -327,6 +317,11 @@ async fn connect(
327317
328318 #[ cfg( target_os = "windows" ) ]
329319 "pipe" => {
320+ use std:: time:: Duration ;
321+
322+ use tokio:: net:: windows:: named_pipe:: ClientOptions ;
323+ use windows_sys:: Win32 :: Foundation :: ERROR_PIPE_BUSY ;
324+
330325 let mut pipe_name = url. path ( ) ;
331326 if url. host_str ( ) . is_some ( ) {
332327 pipe_name = pipe_name. strip_prefix ( '/' ) . unwrap_or ( pipe_name) ;
@@ -353,7 +348,7 @@ async fn connect(
353348 Err ( error) => return Err ( error) ,
354349 }
355350
356- time:: sleep ( Duration :: from_millis ( 50 ) ) . await ;
351+ tokio :: time:: sleep ( Duration :: from_millis ( 50 ) ) . await ;
357352 } ;
358353 Box :: new ( local_conn)
359354 }
0 commit comments