Commit e8b524b 1 parent 4a0b6ee commit e8b524b Copy full SHA for e8b524b
File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ use std::sync::mpsc;
13
13
use std:: thread;
14
14
use std:: time:: Instant ;
15
15
16
+ #[ cfg( feature = "basic-auth" ) ]
17
+ use base64:: Engine ;
18
+
16
19
use url:: { Host , Url } ;
17
20
18
21
use crate :: happy;
@@ -91,6 +94,16 @@ impl BaseStream {
91
94
write ! ( stream, "CONNECT {remote_host}:{remote_port} HTTP/1.1\r \n " ) ?;
92
95
write ! ( stream, "Host: {proxy_host}:{proxy_port}\r \n " ) ?;
93
96
write ! ( stream, "Connection: close\r \n " ) ?;
97
+ #[ cfg( feature = "basic-auth" ) ]
98
+ if proxy_url. has_authority ( ) {
99
+ let username = proxy_url. username ( ) ;
100
+ let auth = match proxy_url. password ( ) {
101
+ Some ( password) => format ! ( "{username}:{password}" ) ,
102
+ None => format ! ( "{username}:" ) ,
103
+ } ;
104
+ let basic_auth = base64:: engine:: general_purpose:: STANDARD . encode ( auth) ;
105
+ write ! ( stream, "Proxy-Authorization: Basic {basic_auth}\r \n " ) ?;
106
+ }
94
107
write ! ( stream, "\r \n " ) ?;
95
108
96
109
let mut stream = BufReaderWrite :: new ( stream) ;
You can’t perform that action at this time.
0 commit comments