@@ -62,12 +62,15 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
6262
6363 Request . ParseRequestLine ( httpCmd ! , out string _ , out string httpUrl , out var version ) ;
6464
65- var httpRemoteUri = new Uri ( "http://" + httpUrl ) ;
66- connectHostname = httpRemoteUri . Host ;
65+ connectHostname = httpUrl ;
66+ int idx = connectHostname . IndexOf ( ":" ) ;
67+ if ( idx >= 0 )
68+ {
69+ connectHostname = connectHostname . Substring ( 0 , idx ) ;
70+ }
6771
68- var connectRequest = new ConnectRequest
72+ var connectRequest = new ConnectRequest ( connectHostname )
6973 {
70- RequestUri = httpRemoteUri ,
7174 OriginalUrlData = HttpHeader . Encoding . GetBytes ( httpUrl ) ,
7275 HttpVersion = version
7376 } ;
@@ -127,6 +130,7 @@ await clientStreamWriter.WriteResponseAsync(connectArgs.HttpClient.Response,
127130 bool isClientHello = clientHelloInfo != null ;
128131 if ( clientHelloInfo != null )
129132 {
133+ connectRequest . Scheme = ProxyServer . UriSchemeHttps ;
130134 connectRequest . TunnelType = TunnelType . Https ;
131135 connectRequest . ClientHelloInfo = clientHelloInfo ;
132136 }
@@ -136,7 +140,6 @@ await clientStreamWriter.WriteResponseAsync(connectArgs.HttpClient.Response,
136140 if ( decryptSsl && clientHelloInfo != null )
137141 {
138142 clientConnection . SslProtocol = clientHelloInfo . SslProtocol ;
139- connectRequest . RequestUri = new Uri ( "https://" + httpUrl ) ;
140143
141144 bool http2Supported = false ;
142145
@@ -355,7 +358,7 @@ await Http2Helper.SendHttp2(clientStream, connection.Stream,
355358
356359 // Now create the request
357360 await handleHttpSessionRequest ( endPoint , clientConnection , clientStream , clientStreamWriter ,
358- cancellationTokenSource , connectHostname , connectArgs , prefetchConnectionTask ) ;
361+ cancellationTokenSource , connectArgs , prefetchConnectionTask ) ;
359362 }
360363 catch ( ProxyException e )
361364 {
0 commit comments