@@ -52,18 +52,16 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
5252 if ( await HttpHelper . IsConnectMethod ( clientStream , BufferPool , cancellationToken ) == 1 )
5353 {
5454 // read the first line HTTP command
55- string ? httpCmd = await clientStream . ReadLineAsync ( cancellationToken ) ;
56- if ( string . IsNullOrEmpty ( httpCmd ) )
55+ var requestLine = await clientStream . ReadRequestLine ( cancellationToken ) ;
56+ if ( requestLine . IsEmpty ( ) )
5757 {
5858 return ;
5959 }
6060
61- Request . ParseRequestLine ( httpCmd ! , out string _ , out var httpUrl , out var version ) ;
62-
63- var connectRequest = new ConnectRequest ( httpUrl . GetString ( ) )
61+ var connectRequest = new ConnectRequest ( requestLine . RequestUri . GetString ( ) )
6462 {
65- RequestUriString8 = httpUrl ,
66- HttpVersion = version
63+ RequestUriString8 = requestLine . RequestUri ,
64+ HttpVersion = requestLine . Version
6765 } ;
6866
6967 await HeaderParser . ReadHeaders ( clientStream , connectRequest . Headers , cancellationToken ) ;
@@ -105,7 +103,7 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
105103 }
106104
107105 // write back successful CONNECT response
108- var response = ConnectResponse . CreateSuccessfulConnectResponse ( version ) ;
106+ var response = ConnectResponse . CreateSuccessfulConnectResponse ( requestLine . Version ) ;
109107
110108 // Set ContentLength explicitly to properly handle HTTP 1.0
111109 response . ContentLength = 0 ;
@@ -175,7 +173,7 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
175173 }
176174 }
177175
178- string connectHostname = httpUrl . GetString ( ) ;
176+ string connectHostname = requestLine . RequestUri . GetString ( ) ;
179177 int idx = connectHostname . IndexOf ( ":" ) ;
180178 if ( idx >= 0 )
181179 {
@@ -214,6 +212,8 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
214212
215213 // HTTPS server created - we can now decrypt the client's traffic
216214 clientStream = new HttpClientStream ( sslStream , BufferPool ) ;
215+ sslStream = null ; // clientStream was created, no need to keep SSL stream reference
216+
217217 clientStream . DataRead += ( o , args ) => connectArgs . OnDecryptedDataSent ( args . Buffer , args . Offset , args . Count ) ;
218218 clientStream . DataWrite += ( o , args ) => connectArgs . OnDecryptedDataReceived ( args . Buffer , args . Offset , args . Count ) ;
219219 }
0 commit comments