@@ -878,7 +878,7 @@ await connection.Receive(
878
878
It . IsAny < string > ( ) ,
879
879
It . IsAny < string > ( ) ,
880
880
It . Is < InvalidOperationException > ( ex =>
881
- ex . Message . Equals ( $ "Response Content-Length mismatch: too few bytes written (12 of 13)." , StringComparison . Ordinal ) ) ) ) ;
881
+ ex . Message . Equals ( CoreStrings . FormatTooFewBytesWritten ( 12 , 13 ) , StringComparison . Ordinal ) ) ) ) ;
882
882
}
883
883
884
884
[ Fact ]
@@ -936,7 +936,7 @@ await connection.Receive(
936
936
It . IsAny < string > ( ) ,
937
937
It . IsAny < string > ( ) ,
938
938
It . Is < InvalidOperationException > ( ex =>
939
- ex . Message . Equals ( $ "Response Content-Length mismatch: too few bytes written (12 of 13)." , StringComparison . Ordinal ) ) ) ) ;
939
+ ex . Message . Equals ( CoreStrings . FormatTooFewBytesWritten ( 12 , 13 ) , StringComparison . Ordinal ) ) ) ) ;
940
940
941
941
Assert . NotNull ( completeEx ) ;
942
942
}
@@ -1025,7 +1025,7 @@ await connection.Receive(
1025
1025
1026
1026
var error = TestApplicationErrorLogger . Messages . Where ( message => message . LogLevel == LogLevel . Error ) ;
1027
1027
Assert . Equal ( 2 , error . Count ( ) ) ;
1028
- Assert . All ( error , message => message . Message . Equals ( "Response Content-Length mismatch: too few bytes written (0 of 5)." ) ) ;
1028
+ Assert . All ( error , message => message . Message . Equals ( CoreStrings . FormatTooFewBytesWritten ( 0 , 5 ) ) ) ;
1029
1029
}
1030
1030
1031
1031
[ Theory ]
@@ -3550,7 +3550,7 @@ await connection.Receive(
3550
3550
}
3551
3551
3552
3552
[ Fact ]
3553
- public async Task ResponseBodyWriterCompleteWithoutExceptionWritesDoesThrow ( )
3553
+ public async Task ResponseBodyWriterCompleteWithoutExceptionNextWriteDoesThrow ( )
3554
3554
{
3555
3555
InvalidOperationException writeEx = null ;
3556
3556
@@ -3580,6 +3580,40 @@ await connection.Receive(
3580
3580
Assert . NotNull ( writeEx ) ;
3581
3581
}
3582
3582
3583
+ [ Fact ]
3584
+ public async Task ResponseBodyWriterCompleteFlushesChunkTerminator ( )
3585
+ {
3586
+ var middlewareCompletionTcs = new TaskCompletionSource ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
3587
+
3588
+ await using var server = new TestServer ( async httpContext =>
3589
+ {
3590
+ await httpContext . Response . WriteAsync ( "hello, world" ) ;
3591
+ await httpContext . Response . BodyWriter . CompleteAsync ( ) ;
3592
+ await middlewareCompletionTcs . Task ;
3593
+ } , new TestServiceContext ( LoggerFactory ) ) ;
3594
+
3595
+ using var connection = server . CreateConnection ( ) ;
3596
+
3597
+ await connection . Send (
3598
+ "GET / HTTP/1.1" ,
3599
+ "Host:" ,
3600
+ "" ,
3601
+ "" ) ;
3602
+
3603
+ await connection . Receive (
3604
+ "HTTP/1.1 200 OK" ,
3605
+ $ "Date: { server . Context . DateHeaderValue } ",
3606
+ "Transfer-Encoding: chunked" ,
3607
+ "" ,
3608
+ "c" ,
3609
+ "hello, world" ,
3610
+ "0" ,
3611
+ "" ,
3612
+ "" ) ;
3613
+
3614
+ middlewareCompletionTcs . SetResult ( ) ;
3615
+ }
3616
+
3583
3617
[ Fact ]
3584
3618
public async Task ResponseAdvanceStateIsResetWithMultipleReqeusts ( )
3585
3619
{
@@ -3912,7 +3946,6 @@ await connection.Receive(
3912
3946
}
3913
3947
}
3914
3948
3915
-
3916
3949
[ Fact ]
3917
3950
public async Task ResponseGetMemoryAndStartAsyncAdvanceThrows ( )
3918
3951
{
0 commit comments