@@ -34,10 +34,6 @@ private async Task handleClient(TransparentProxyEndPoint endPoint, TcpClientConn
34
34
var clientStream = new CustomBufferedStream ( clientConnection . GetStream ( ) , BufferPool , BufferSize ) ;
35
35
var clientStreamWriter = new HttpResponseWriter ( clientStream , BufferPool , BufferSize ) ;
36
36
37
- Task < TcpServerConnection > prefetchConnectionTask = null ;
38
- bool closeServerConnection = false ;
39
- bool calledRequestHandler = false ;
40
-
41
37
try
42
38
{
43
39
var clientHelloInfo = await SslTools . PeekClientHello ( clientStream , BufferPool , cancellationToken ) ;
@@ -63,16 +59,7 @@ private async Task handleClient(TransparentProxyEndPoint endPoint, TcpClientConn
63
59
64
60
if ( endPoint . DecryptSsl && args . DecryptSsl )
65
61
{
66
- if ( EnableTcpServerConnectionPrefetch )
67
- {
68
- //don't pass cancellation token here
69
- //it could cause floating server connections when client exits
70
- prefetchConnectionTask = tcpConnectionFactory . GetServerConnection ( httpsHostName , endPoint . Port ,
71
- httpVersion : null , isHttps : true , applicationProtocols : null , isConnect : false ,
72
- proxyServer : this , session : null , upStreamEndPoint : UpStreamEndPoint , externalProxy : UpStreamHttpsProxy ,
73
- noCache : false , cancellationToken : CancellationToken . None ) ;
74
- }
75
-
62
+
76
63
SslStream sslStream = null ;
77
64
78
65
//do client authentication using fake certificate
@@ -140,39 +127,29 @@ await TcpHelper.SendRaw(clientStream, serverStream, BufferPool, BufferSize,
140
127
return ;
141
128
}
142
129
}
143
- calledRequestHandler = true ;
144
130
// HTTPS server created - we can now decrypt the client's traffic
145
131
// Now create the request
146
132
await handleHttpSessionRequest ( endPoint , clientConnection , clientStream , clientStreamWriter ,
147
- cancellationTokenSource , isHttps ? httpsHostName : null , null , prefetchConnectionTask ) ;
133
+ cancellationTokenSource , isHttps ? httpsHostName : null , null , null ) ;
148
134
}
149
135
catch ( ProxyException e )
150
136
{
151
- closeServerConnection = true ;
152
137
onException ( clientStream , e ) ;
153
138
}
154
139
catch ( IOException e )
155
140
{
156
- closeServerConnection = true ;
157
141
onException ( clientStream , new Exception ( "Connection was aborted" , e ) ) ;
158
142
}
159
143
catch ( SocketException e )
160
144
{
161
- closeServerConnection = true ;
162
145
onException ( clientStream , new Exception ( "Could not connect" , e ) ) ;
163
146
}
164
147
catch ( Exception e )
165
148
{
166
- closeServerConnection = true ;
167
149
onException ( clientStream , new Exception ( "Error occured in whilst handling the client" , e ) ) ;
168
150
}
169
151
finally
170
152
{
171
- if ( ! calledRequestHandler )
172
- {
173
- await tcpConnectionFactory . Release ( prefetchConnectionTask , closeServerConnection ) ;
174
- }
175
-
176
153
clientStream . Dispose ( ) ;
177
154
178
155
if ( ! cancellationTokenSource . IsCancellationRequested )
0 commit comments