@@ -1890,6 +1890,11 @@ class ServerTest : public ::testing::Test {
1890
1890
[&](const Request & /* req*/ , Response &res) {
1891
1891
res.set_content (" abcdefg" , " text/plain" );
1892
1892
})
1893
+ .Get (" /with-range-customized-response" ,
1894
+ [&](const Request & /* req*/ , Response &res) {
1895
+ res.status = StatusCode::BadRequest_400;
1896
+ res.set_content (JSON_DATA, " application/json" );
1897
+ })
1893
1898
.Post (" /chunked" ,
1894
1899
[&](const Request &req, Response & /* res*/ ) {
1895
1900
EXPECT_EQ (req.body , " dechunked post body" );
@@ -3166,6 +3171,24 @@ TEST_F(ServerTest, GetWithRangeMultipartOffsetGreaterThanContent) {
3166
3171
EXPECT_EQ (StatusCode::RangeNotSatisfiable_416, res->status );
3167
3172
}
3168
3173
3174
+ TEST_F (ServerTest, GetWithRangeCustomizedResponse) {
3175
+ auto res = cli_.Get (" /with-range-customized-response" , {{make_range_header ({{1 , 2 }})}});
3176
+ ASSERT_TRUE (res);
3177
+ EXPECT_EQ (StatusCode::BadRequest_400, res->status );
3178
+ EXPECT_EQ (true , res->has_header (" Content-Length" ));
3179
+ EXPECT_EQ (false , res->has_header (" Content-Range" ));
3180
+ EXPECT_EQ (JSON_DATA, res->body );
3181
+ }
3182
+
3183
+ TEST_F (ServerTest, GetWithRangeMultipartCustomizedResponseMultipleRange) {
3184
+ auto res = cli_.Get (" /with-range-customized-response" , {{make_range_header ({{1 , 2 }, {4 , 5 }})}});
3185
+ ASSERT_TRUE (res);
3186
+ EXPECT_EQ (StatusCode::BadRequest_400, res->status );
3187
+ EXPECT_EQ (true , res->has_header (" Content-Length" ));
3188
+ EXPECT_EQ (false , res->has_header (" Content-Range" ));
3189
+ EXPECT_EQ (JSON_DATA, res->body );
3190
+ }
3191
+
3169
3192
TEST_F (ServerTest, Issue1772) {
3170
3193
auto res = cli_.Get (" /issue1772" , {{make_range_header ({{1000 , -1 }})}});
3171
3194
ASSERT_TRUE (res);
0 commit comments