File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed 
src/Servers/Kestrel/test/InMemory.FunctionalTests Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -400,20 +400,24 @@ public async Task Http1Connection_ServerAbort_HasErrorType()
400400        var  serviceContext  =  new  TestServiceContext ( LoggerFactory ,  metrics :  new  KestrelMetrics ( testMeterFactory ) ) ; 
401401
402402        var  sendString  =  "POST / HTTP/1.0\r \n Content-Length: 12\r \n \r \n Hello World?" ; 
403-         var  readBodyTcs  =  new  TaskCompletionSource ( TaskCreationOptions . RunContinuationsAsynchronously ) ; 
403+         var  finishedSendingTcs  =  new  TaskCompletionSource ( TaskCreationOptions . RunContinuationsAsynchronously ) ; 
404404
405405        await  using  var  server  =  new  TestServer ( async  c => 
406406        { 
407407            await  c . Request . Body . ReadUntilEndAsync ( ) ; 
408-             readBodyTcs . SetResult ( ) ; 
408+ 
409+             // An extra check to ensure that client is done sending before the server aborts. 
410+             // This might not be necessary since we're reading to the end of the request body, but it doesn't hurt. 
411+             await  finishedSendingTcs . Task ; 
412+ 
409413            c . Abort ( ) ; 
410414        } ,  serviceContext ) ; 
411415
412416        using  ( var  connection  =  server . CreateConnection ( ) ) 
413417        { 
414418            await  connection . Send ( sendString ) . DefaultTimeout ( ) ; 
415419
416-             await   readBodyTcs . Task . DefaultTimeout ( ) ; 
420+             finishedSendingTcs . SetResult ( ) ; 
417421
418422            await  connection . ReceiveEnd ( ) . DefaultTimeout ( ) ; 
419423
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments