@@ -186,6 +186,7 @@ await HandleHttpSessionRequest(tcpClient, httpCmd, clientStream, clientStreamRea
186
186
private static async Task HandleHttpSessionRequest ( TcpClient client , string httpCmd , Stream clientStream ,
187
187
CustomBinaryReader clientStreamReader , StreamWriter clientStreamWriter , bool isHttps )
188
188
{
189
+ TcpConnection connection = null ;
189
190
190
191
while ( true )
191
192
{
@@ -268,7 +269,7 @@ await TcpHelper.SendRaw(clientStream, httpCmd, args.WebSession.Request.RequestHe
268
269
}
269
270
270
271
//construct the web request that we are going to issue on behalf of the client.
271
- var connection = await TcpConnectionManager . GetClient ( args . WebSession . Request . RequestUri . Host , args . WebSession . Request . RequestUri . Port , args . IsHttps , version ) . ConfigureAwait ( false ) ;
272
+ connection = await TcpConnectionManager . GetClient ( args . WebSession . Request . RequestUri . Host , args . WebSession . Request . RequestUri . Port , args . IsHttps , version ) . ConfigureAwait ( false ) ;
272
273
273
274
274
275
args . WebSession . Request . RequestLocked = true ;
@@ -342,8 +343,6 @@ await WriteResponseStatus(args.WebSession.Response.HttpVersion, "417",
342
343
return ;
343
344
}
344
345
345
- await TcpConnectionManager . ReleaseClient ( connection ) ;
346
-
347
346
// read the next request
348
347
httpCmd = await clientStreamReader . ReadLineAsync ( ) . ConfigureAwait ( false ) ;
349
348
@@ -356,6 +355,8 @@ await WriteResponseStatus(args.WebSession.Response.HttpVersion, "417",
356
355
357
356
}
358
357
358
+ if ( connection != null )
359
+ await TcpConnectionManager . ReleaseClient ( connection ) ;
359
360
}
360
361
361
362
private static async Task WriteConnectResponse ( StreamWriter clientStreamWriter , Version httpVersion )
0 commit comments