From 2d01e712866d3ed17d33569b8fa5345f5cade146 Mon Sep 17 00:00:00 2001 From: Paul Harris Date: Tue, 10 Sep 2024 05:54:11 +0800 Subject: [PATCH] Test reading empty zero-length file (#1931) --- test/test.cc | 9 +++++++++ test/www/empty_file | 0 2 files changed, 9 insertions(+) create mode 100644 test/www/empty_file diff --git a/test/test.cc b/test/test.cc index e3e202a749..a0fd061529 100644 --- a/test/test.cc +++ b/test/test.cc @@ -2916,6 +2916,15 @@ TEST_F(ServerTest, GetMethod200) { EXPECT_EQ("Hello World!", res->body); } +TEST_F(ServerTest, GetEmptyFile) { + auto res = cli_.Get("/empty_file"); + ASSERT_TRUE(res); + EXPECT_EQ(StatusCode::OK_200, res->status); + EXPECT_EQ("text/plain", res->get_header_value("Content-Type")); + EXPECT_EQ(0, std::stoi(res->get_header_value("Content-Length"))); + EXPECT_EQ("", res->body); +} + TEST_F(ServerTest, GetFileContent) { auto res = cli_.Get("/file_content"); ASSERT_TRUE(res); diff --git a/test/www/empty_file b/test/www/empty_file new file mode 100644 index 0000000000..e69de29bb2