@@ -989,6 +989,33 @@ public async Task IfUnmodifiedSinceDateLessThanLastModifiedShouldReturn412(HttpM
989989 Assert . Equal ( HttpStatusCode . PreconditionFailed , res2 . StatusCode ) ;
990990 }
991991
992+ // 14.35.2 Range Retrieval Requests
993+ // The presence of a Range header in an unconditional GET modifies
994+ // what is returned if the GET is otherwise successful. In other
995+ // words, the response carries a status code of 206 (Partial
996+ // Content) instead of 200 (OK).
997+ [ Fact ]
998+ public async Task RangeGivesMatchingRange ( )
999+ {
1000+ var client = await CreateClient ( ) ;
1001+
1002+ var req1 = new HttpRequestMessage ( HttpMethod . Get , "http://localhost/sample.txt" ) ;
1003+ req1 . Headers . Range = new RangeHeaderValue ( 0 , 4 ) ;
1004+ var res1 = await client . SendAsync ( req1 ) ;
1005+
1006+ var req2 = new HttpRequestMessage ( HttpMethod . Get , "http://localhost/sample.txt" ) ;
1007+ req2 . Headers . Range = new RangeHeaderValue ( 7 , 11 ) ;
1008+ var res2 = await client . SendAsync ( req2 ) ;
1009+
1010+ Assert . Equal ( HttpStatusCode . PartialContent , res1 . StatusCode ) ;
1011+ Assert . Equal ( "Hello" , await res1 . Content . ReadAsStringAsync ( ) ) ;
1012+ Assert . Equal ( 5 , res1 . Content . Headers . ContentLength ) ;
1013+
1014+ Assert . Equal ( HttpStatusCode . PartialContent , res2 . StatusCode ) ;
1015+ Assert . Equal ( "World" , await res2 . Content . ReadAsStringAsync ( ) ) ;
1016+ Assert . Equal ( 5 , res2 . Content . Headers . ContentLength ) ;
1017+ }
1018+
9921019 public static IEnumerable < object [ ] > SupportedMethods => new [ ]
9931020 {
9941021 new [ ] { HttpMethod . Get } ,
0 commit comments