@@ -537,6 +537,58 @@ public async Task POST_ServerAbort_ClientReceivesAbort(HttpProtocols protocol)
537
537
}
538
538
}
539
539
540
+ [ ConditionalFact ]
541
+ [ MsQuicSupported ]
542
+ public async Task POST_ServerAbortAfterWrite_ClientReceivesAbort ( )
543
+ {
544
+ // Arrange
545
+ var builder = CreateHostBuilder ( async context =>
546
+ {
547
+ Logger . LogInformation ( "Server writing content." ) ;
548
+ await context . Response . Body . WriteAsync ( new byte [ 16 ] ) ;
549
+
550
+ // Note that there is a race here on what is sent before the abort is processed.
551
+ // Abort may happen before or after response headers have been sent.
552
+ Logger . LogInformation ( "Server aborting." ) ;
553
+ context . Abort ( ) ;
554
+ } , protocol : HttpProtocols . Http3 ) ;
555
+
556
+ using ( var host = builder . Build ( ) )
557
+ using ( var client = HttpHelpers . CreateClient ( ) )
558
+ {
559
+ await host . StartAsync ( ) . DefaultTimeout ( ) ;
560
+
561
+ for ( var i = 0 ; i < 100 ; i ++ )
562
+ {
563
+ Logger . LogInformation ( $ "Client sending request { i } ") ;
564
+
565
+ var request = new HttpRequestMessage ( HttpMethod . Get , $ "https://127.0.0.1:{ host . GetPort ( ) } /") ;
566
+ request . Version = GetProtocol ( HttpProtocols . Http3 ) ;
567
+ request . VersionPolicy = HttpVersionPolicy . RequestVersionExact ;
568
+
569
+ // Act
570
+ var sendTask = client . SendAsync ( request , CancellationToken . None ) ;
571
+
572
+ // Assert
573
+ var ex = await Assert . ThrowsAsync < HttpRequestException > ( async ( ) =>
574
+ {
575
+ // Note that there is a race here on what is sent before the abort is processed.
576
+ // Abort may happen before or after response headers have been sent.
577
+ Logger . LogInformation ( $ "Client awaiting response { i } ") ;
578
+ var response = await sendTask ;
579
+
580
+ Logger . LogInformation ( $ "Client awaiting content { i } ") ;
581
+ await response . Content . ReadAsByteArrayAsync ( ) ;
582
+ } ) . DefaultTimeout ( ) ;
583
+
584
+ var protocolException = ex . GetProtocolException ( ) ;
585
+ Assert . Equal ( ( long ) Http3ErrorCode . InternalError , protocolException . ErrorCode ) ;
586
+ }
587
+
588
+ await host . StopAsync ( ) . DefaultTimeout ( ) ;
589
+ }
590
+ }
591
+
540
592
// Verify HTTP/2 and HTTP/3 match behavior
541
593
[ ConditionalTheory ]
542
594
[ MsQuicSupported ]
0 commit comments