|
|
@@ -27144,13 +27144,35 @@ TEST(ETagTest, IfRangeWithDate) {
|
|
|
EXPECT_EQ(200, res3->status);
|
|
|
EXPECT_EQ(content, res3->body);
|
|
|
|
|
|
- // Range request with future If-Range date: should get 206
|
|
|
+ // Range request with future If-Range date: should get 200 (full content)
|
|
|
Headers h4 = {{"Range", "bytes=0-4"},
|
|
|
{"If-Range", "Sun, 01 Jan 2099 00:00:00 GMT"}};
|
|
|
auto res4 = cli.Get("/static/if_range_date_testfile.txt", h4);
|
|
|
ASSERT_TRUE(res4);
|
|
|
- EXPECT_EQ(206, res4->status);
|
|
|
- EXPECT_EQ("ABCDE", res4->body);
|
|
|
+ EXPECT_EQ(200, res4->status);
|
|
|
+ EXPECT_EQ(content, res4->body);
|
|
|
+
|
|
|
+#if defined(__APPLE__) || defined(__linux__)
|
|
|
+ // File replaced by one with an older mtime: should get 200 (full content)
|
|
|
+ const std::string replaced = "abcdefghij9876543210";
|
|
|
+ {
|
|
|
+ std::ofstream ofs(fname);
|
|
|
+ ofs << replaced;
|
|
|
+ ASSERT_TRUE(ofs.good());
|
|
|
+ }
|
|
|
+ struct timeval times[2];
|
|
|
+ times[0].tv_sec = time(nullptr);
|
|
|
+ times[0].tv_usec = 0;
|
|
|
+ times[1].tv_sec = time(nullptr) - 3600;
|
|
|
+ times[1].tv_usec = 0;
|
|
|
+ ASSERT_EQ(0, utimes(fname, times));
|
|
|
+
|
|
|
+ Headers h5 = {{"Range", "bytes=5-9"}, {"If-Range", last_modified}};
|
|
|
+ auto res5 = cli.Get("/static/if_range_date_testfile.txt", h5);
|
|
|
+ ASSERT_TRUE(res5);
|
|
|
+ EXPECT_EQ(200, res5->status);
|
|
|
+ EXPECT_EQ(replaced, res5->body);
|
|
|
+#endif
|
|
|
|
|
|
svr.stop();
|
|
|
t.join();
|