@@ -247,16 +247,16 @@ public async Task FileFromDisk_ReturnsFileWithFileName_IfRangeHeaderInvalid_Rang
247
247
}
248
248
249
249
[ Theory ]
250
- [ InlineData ( "" , HttpStatusCode . OK ) ]
251
- [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent ) ]
252
- [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent ) ]
253
- [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent ) ]
254
- [ InlineData ( "0-6" , HttpStatusCode . OK ) ]
255
- [ InlineData ( "bytes = " , HttpStatusCode . OK ) ]
256
- [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK ) ]
257
- [ InlineData ( "bytes = 35-36" , HttpStatusCode . RequestedRangeNotSatisfiable ) ]
258
- [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable ) ]
259
- public async Task FileFromDisk_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest_WithLastModifiedAndEtag ( string rangeString , HttpStatusCode httpStatusCode )
250
+ [ InlineData ( "" , HttpStatusCode . OK , 26 ) ]
251
+ [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent , 7 ) ]
252
+ [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent , 9 ) ]
253
+ [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent , 26 ) ]
254
+ [ InlineData ( "0-6" , HttpStatusCode . OK , 26 ) ]
255
+ [ InlineData ( "bytes = " , HttpStatusCode . OK , 26 ) ]
256
+ [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK , 26 ) ]
257
+ [ InlineData ( "bytes = 35-36" , HttpStatusCode . RequestedRangeNotSatisfiable , 26 ) ]
258
+ [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable , 26 ) ]
259
+ public async Task FileFromDisk_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest_WithLastModifiedAndEtag ( string rangeString , HttpStatusCode httpStatusCode , int expectedContentLength )
260
260
{
261
261
// Arrange
262
262
var httpRequestMessage = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/DownloadFiles/DownloadFromDiskWithFileName_WithLastModifiedAndEtag" ) ;
@@ -276,6 +276,9 @@ public async Task FileFromDisk_ReturnsFileWithFileName_DoesNotServeBody_ForHeadR
276
276
Assert . NotNull ( body ) ;
277
277
Assert . Equal ( string . Empty , body ) ;
278
278
279
+ var contentLength = response . Content . Headers . ContentLength ;
280
+ Assert . Equal ( expectedContentLength , contentLength ) ;
281
+
279
282
var contentDisposition = response . Content . Headers . ContentDisposition . ToString ( ) ;
280
283
Assert . NotNull ( contentDisposition ) ;
281
284
Assert . Equal ( "attachment; filename=downloadName.txt; filename*=UTF-8''downloadName.txt" , contentDisposition ) ;
@@ -440,16 +443,16 @@ public async Task FileFromStream_ReturnsFileWithFileName_IfRangeHeaderInvalid_Ra
440
443
}
441
444
442
445
[ Theory ]
443
- [ InlineData ( "" , HttpStatusCode . OK ) ]
444
- [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent ) ]
445
- [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent ) ]
446
- [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent ) ]
447
- [ InlineData ( "0-6" , HttpStatusCode . OK ) ]
448
- [ InlineData ( "bytes = " , HttpStatusCode . OK ) ]
449
- [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK ) ]
450
- [ InlineData ( "bytes = 35-36" , HttpStatusCode . RequestedRangeNotSatisfiable ) ]
451
- [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable ) ]
452
- public async Task FileFromStream_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode )
446
+ [ InlineData ( "" , HttpStatusCode . OK , 33 ) ]
447
+ [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent , 7 ) ]
448
+ [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent , 9 ) ]
449
+ [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent , 33 ) ]
450
+ [ InlineData ( "0-6" , HttpStatusCode . OK , 33 ) ]
451
+ [ InlineData ( "bytes = " , HttpStatusCode . OK , 33 ) ]
452
+ [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK , 33 ) ]
453
+ [ InlineData ( "bytes = 35-36" , HttpStatusCode . RequestedRangeNotSatisfiable , 33 ) ]
454
+ [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable , 33 ) ]
455
+ public async Task FileFromStream_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode , int expectedContentLength )
453
456
{
454
457
// Arrange
455
458
var httpRequestMessage = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/DownloadFiles/DownloadFromStreamWithFileName_WithEtag" ) ;
@@ -469,6 +472,9 @@ public async Task FileFromStream_ReturnsFileWithFileName_DoesNotServeBody_ForHea
469
472
Assert . NotNull ( body ) ;
470
473
Assert . Equal ( string . Empty , body ) ;
471
474
475
+ var contentLength = response . Content . Headers . ContentLength ;
476
+ Assert . Equal ( expectedContentLength , contentLength ) ;
477
+
472
478
var contentDisposition = response . Content . Headers . ContentDisposition . ToString ( ) ;
473
479
Assert . NotNull ( contentDisposition ) ;
474
480
Assert . Equal ( "attachment; filename=downloadName.txt; filename*=UTF-8''downloadName.txt" , contentDisposition ) ;
@@ -638,16 +644,16 @@ public async Task FileFromBinaryData_ReturnsFileWithFileName_IfRangeHeaderInvali
638
644
}
639
645
640
646
[ Theory ]
641
- [ InlineData ( "" , HttpStatusCode . OK ) ]
642
- [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent ) ]
643
- [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent ) ]
644
- [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent ) ]
645
- [ InlineData ( "0-6" , HttpStatusCode . OK ) ]
646
- [ InlineData ( "bytes = " , HttpStatusCode . OK ) ]
647
- [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK ) ]
648
- [ InlineData ( "bytes = 45-46" , HttpStatusCode . RequestedRangeNotSatisfiable ) ]
649
- [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable ) ]
650
- public async Task FileFromBinaryData_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode )
647
+ [ InlineData ( "" , HttpStatusCode . OK , 41 ) ]
648
+ [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent , 7 ) ]
649
+ [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent , 9 ) ]
650
+ [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent , 41 ) ]
651
+ [ InlineData ( "0-6" , HttpStatusCode . OK , 41 ) ]
652
+ [ InlineData ( "bytes = " , HttpStatusCode . OK , 41 ) ]
653
+ [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK , 41 ) ]
654
+ [ InlineData ( "bytes = 45-46" , HttpStatusCode . RequestedRangeNotSatisfiable , 41 ) ]
655
+ [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable , 41 ) ]
656
+ public async Task FileFromBinaryData_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode , int expectedContentLength )
651
657
{
652
658
// Arrange
653
659
var httpRequestMessage = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/DownloadFiles/DownloadFromBinaryDataWithFileName_WithEtag" ) ;
@@ -667,6 +673,9 @@ public async Task FileFromBinaryData_ReturnsFileWithFileName_DoesNotServeBody_Fo
667
673
Assert . NotNull ( body ) ;
668
674
Assert . Equal ( string . Empty , body ) ;
669
675
676
+ var contentLength = response . Content . Headers . ContentLength ;
677
+ Assert . Equal ( expectedContentLength , contentLength ) ;
678
+
670
679
var contentDisposition = response . Content . Headers . ContentDisposition . ToString ( ) ;
671
680
Assert . NotNull ( contentDisposition ) ;
672
681
Assert . Equal ( "attachment; filename=downloadName.txt; filename*=UTF-8''downloadName.txt" , contentDisposition ) ;
@@ -834,16 +843,16 @@ public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_RangeRequest
834
843
}
835
844
836
845
[ Theory ]
837
- [ InlineData ( "" , HttpStatusCode . OK ) ]
838
- [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent ) ]
839
- [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent ) ]
840
- [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent ) ]
841
- [ InlineData ( "0-6" , HttpStatusCode . OK ) ]
842
- [ InlineData ( "bytes = " , HttpStatusCode . OK ) ]
843
- [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK ) ]
844
- [ InlineData ( "bytes = 45-46" , HttpStatusCode . RequestedRangeNotSatisfiable ) ]
845
- [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable ) ]
846
- public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode )
846
+ [ InlineData ( "" , HttpStatusCode . OK , 38 ) ]
847
+ [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent , 7 ) ]
848
+ [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent , 9 ) ]
849
+ [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent , 38 ) ]
850
+ [ InlineData ( "0-6" , HttpStatusCode . OK , 38 ) ]
851
+ [ InlineData ( "bytes = " , HttpStatusCode . OK , 38 ) ]
852
+ [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK , 38 ) ]
853
+ [ InlineData ( "bytes = 45-46" , HttpStatusCode . RequestedRangeNotSatisfiable , 38 ) ]
854
+ [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable , 38 ) ]
855
+ public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode , int expectedContentLength )
847
856
{
848
857
// Arrange
849
858
var httpRequestMessage = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/EmbeddedFiles/DownloadFileWithFileName" ) ;
@@ -863,6 +872,9 @@ public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_DoesNotServe
863
872
Assert . NotNull ( body ) ;
864
873
Assert . Equal ( string . Empty , body ) ;
865
874
875
+ var contentLength = response . Content . Headers . ContentLength ;
876
+ Assert . Equal ( expectedContentLength , contentLength ) ;
877
+
866
878
var contentDisposition = response . Content . Headers . ContentDisposition . ToString ( ) ;
867
879
Assert . NotNull ( contentDisposition ) ;
868
880
Assert . Equal ( "attachment; filename=downloadName.txt; filename*=UTF-8''downloadName.txt" , contentDisposition ) ;
0 commit comments