@@ -257,6 +257,8 @@ private async Task<RetryResult> handleHttpSessionRequest(string requestHttpMetho
257257 TcpServerConnection ? serverConnection , SslApplicationProtocol sslApplicationProtocol ,
258258 CancellationToken cancellationToken , CancellationTokenSource cancellationTokenSource )
259259 {
260+ args . HttpClient . Request . Locked = true ;
261+
260262 // a connection generator task with captured parameters via closure.
261263 Func < Task < TcpServerConnection > > generator = ( ) =>
262264 tcpConnectionFactory . GetServerConnection ( this , args , isConnect : false ,
@@ -266,6 +268,9 @@ private async Task<RetryResult> handleHttpSessionRequest(string requestHttpMetho
266268 // for connection pool, retry fails until cache is exhausted.
267269 return await retryPolicy < ServerConnectionException > ( ) . ExecuteAsync ( async ( connection ) =>
268270 {
271+ // set the connection and send request headers
272+ args . HttpClient . SetConnection ( connection ) ;
273+
269274 args . TimeLine [ "Connection Ready" ] = DateTime . Now ;
270275
271276 if ( args . HttpClient . Request . UpgradeToWebSocket )
@@ -290,12 +295,9 @@ private async Task handleHttpSessionRequest(TcpServerConnection connection, Sess
290295 {
291296 var cancellationToken = args . CancellationTokenSource . Token ;
292297 var request = args . HttpClient . Request ;
293- request . Locked = true ;
294298
295299 var body = request . CompressBodyAndUpdateContentLength ( ) ;
296300
297- // set the connection and send request headers
298- args . HttpClient . SetConnection ( connection ) ;
299301 await args . HttpClient . SendRequest ( Enable100ContinueBehaviour , args . IsTransparent ,
300302 cancellationToken ) ;
301303
0 commit comments