@@ -180,10 +180,34 @@ internal async Task<TcpServerConnection> GetServerConnection(ProxyServer server,
180180
181181 session . CustomUpStreamProxyUsed = customUpStreamProxy ;
182182
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+
184208 return await GetServerConnection (
185- uri . Host ,
186- uri . Port ,
209+ host ,
210+ port ,
187211 session . HttpClient . Request . HttpVersion ,
188212 isHttps , applicationProtocols , isConnect ,
189213 server , session , session . HttpClient . UpStreamEndPoint ?? server . UpStreamEndPoint ,
@@ -426,11 +450,11 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
426450
427451 if ( externalProxy != null && ( isConnect || isHttps ) )
428452 {
429- string authority = $ "{ remoteHostName } :{ remotePort } ";
453+ var authority = $ "{ remoteHostName } :{ remotePort } ". GetByteString ( ) ;
430454 var connectRequest = new ConnectRequest ( authority )
431455 {
432456 IsHttps = isHttps ,
433- RequestUriString8 = HttpHeader . Encoding . GetBytes ( authority ) ,
457+ RequestUriString8 = authority ,
434458 HttpVersion = httpVersion
435459 } ;
436460
0 commit comments