This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
src/Kestrel.Core/Internal/Http
test/Kestrel.FunctionalTests Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -875,6 +875,7 @@ protected void VerifyResponseContentLength()
875
875
var responseHeaders = HttpResponseHeaders ;
876
876
877
877
if ( ! HttpMethods . IsHead ( Method ) &&
878
+ StatusCode != StatusCodes . Status304NotModified &&
878
879
! responseHeaders . HasTransferEncoding &&
879
880
responseHeaders . ContentLength . HasValue &&
880
881
_responseBytesWritten < responseHeaders . ContentLength . Value )
Original file line number Diff line number Diff line change @@ -2662,6 +2662,35 @@ public async Task HttpsConnectionClosedWhenResponseDoesNotSatisfyMinimumDataRate
2662
2662
}
2663
2663
}
2664
2664
2665
+ [ Fact ]
2666
+ public async Task NonZeroContentLengthFor304StatusCodeIsAllowed ( )
2667
+ {
2668
+ using ( var server = new TestServer ( httpContext =>
2669
+ {
2670
+ var response = httpContext . Response ;
2671
+ response . StatusCode = StatusCodes . Status304NotModified ;
2672
+ response . ContentLength = 42 ;
2673
+
2674
+ return Task . CompletedTask ;
2675
+ } ) )
2676
+ {
2677
+ using ( var connection = server . CreateConnection ( ) )
2678
+ {
2679
+ await connection . Send (
2680
+ "GET / HTTP/1.1" ,
2681
+ "Host:" ,
2682
+ "" ,
2683
+ "" ) ;
2684
+ await connection . Receive (
2685
+ "HTTP/1.1 304 Not Modified" ,
2686
+ $ "Date: { server . Context . DateHeaderValue } ",
2687
+ "Content-Length: 42" ,
2688
+ "" ,
2689
+ "" ) ;
2690
+ }
2691
+ }
2692
+ }
2693
+
2665
2694
public static TheoryData < string , StringValues , string > NullHeaderData
2666
2695
{
2667
2696
get
You can’t perform that action at this time.
0 commit comments