@@ -180,10 +180,34 @@ internal async Task<TcpServerConnection> GetServerConnection(ProxyServer server,
180
180
181
181
session . CustomUpStreamProxyUsed = customUpStreamProxy ;
182
182
183
- var uri = session . HttpClient . Request . RequestUri ;
183
+ var request = session . HttpClient . Request ;
184
+ string host ;
185
+ int port ;
186
+ if ( request . Authority . Length > 0 )
187
+ {
188
+ var authority = request . Authority ;
189
+ int idx = authority . IndexOf ( ( byte ) ':' ) ;
190
+ if ( idx == - 1 )
191
+ {
192
+ host = authority . GetString ( ) ;
193
+ port = 80 ;
194
+ }
195
+ else
196
+ {
197
+ host = authority . Slice ( 0 , idx ) . GetString ( ) ;
198
+ port = int . Parse ( authority . Slice ( idx + 1 ) . GetString ( ) ) ;
199
+ }
200
+ }
201
+ else
202
+ {
203
+ var uri = request . RequestUri ;
204
+ host = uri . Host ;
205
+ port = uri . Port ;
206
+ }
207
+
184
208
return await GetServerConnection (
185
- uri . Host ,
186
- uri . Port ,
209
+ host ,
210
+ port ,
187
211
session . HttpClient . Request . HttpVersion ,
188
212
isHttps , applicationProtocols , isConnect ,
189
213
server , session , session . HttpClient . UpStreamEndPoint ?? server . UpStreamEndPoint ,
@@ -426,11 +450,11 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
426
450
427
451
if ( externalProxy != null && ( isConnect || isHttps ) )
428
452
{
429
- string authority = $ "{ remoteHostName } :{ remotePort } ";
453
+ var authority = $ "{ remoteHostName } :{ remotePort } ". GetByteString ( ) ;
430
454
var connectRequest = new ConnectRequest ( authority )
431
455
{
432
456
IsHttps = isHttps ,
433
- RequestUriString8 = HttpHeader . Encoding . GetBytes ( authority ) ,
457
+ RequestUriString8 = authority ,
434
458
HttpVersion = httpVersion
435
459
} ;
436
460
0 commit comments