@@ -1871,6 +1871,12 @@ class ServerTest : public ::testing::Test {
1871
1871
[&](const Request & /* req*/ , Response &res) {
1872
1872
res.set_content (" abcdefg" , " text/plain" );
1873
1873
})
1874
+ .Get (" /with-range-customized-response" ,
1875
+ [&](const Request & /* req*/ , Response &res) {
1876
+ res.ignore_range = true ;
1877
+ res.status = StatusCode::BadRequest_400;
1878
+ res.set_content (JSON_DATA, " application/json" );
1879
+ })
1874
1880
.Post (" /chunked" ,
1875
1881
[&](const Request &req, Response & /* res*/ ) {
1876
1882
EXPECT_EQ (req.body , " dechunked post body" );
@@ -3147,6 +3153,24 @@ TEST_F(ServerTest, GetWithRangeMultipartOffsetGreaterThanContent) {
3147
3153
EXPECT_EQ (StatusCode::RangeNotSatisfiable_416, res->status );
3148
3154
}
3149
3155
3156
+ TEST_F (ServerTest, GetWithRangeCustomizedResponse) {
3157
+ auto res = cli_.Get (" /with-range-customized-response" , {{make_range_header ({{1 , 2 }})}});
3158
+ ASSERT_TRUE (res);
3159
+ EXPECT_EQ (StatusCode::BadRequest_400, res->status );
3160
+ EXPECT_EQ (true , res->has_header (" Content-Length" ));
3161
+ EXPECT_EQ (false , res->has_header (" Content-Range" ));
3162
+ EXPECT_EQ (JSON_DATA, res->body );
3163
+ }
3164
+
3165
+ TEST_F (ServerTest, GetWithRangeMultipartCustomizedResponseMultipleRange) {
3166
+ auto res = cli_.Get (" /with-range-customized-response" , {{make_range_header ({{1 , 2 }, {4 , 5 }})}});
3167
+ ASSERT_TRUE (res);
3168
+ EXPECT_EQ (StatusCode::BadRequest_400, res->status );
3169
+ EXPECT_EQ (true , res->has_header (" Content-Length" ));
3170
+ EXPECT_EQ (false , res->has_header (" Content-Range" ));
3171
+ EXPECT_EQ (JSON_DATA, res->body );
3172
+ }
3173
+
3150
3174
TEST_F (ServerTest, Issue1772) {
3151
3175
auto res = cli_.Get (" /issue1772" , {{make_range_header ({{1000 , -1 }})}});
3152
3176
ASSERT_TRUE (res);
0 commit comments