From cbdb9c251c2406bddbc029a1cad4a50ef5420422 Mon Sep 17 00:00:00 2001 From: Paul Harris Date: Mon, 9 Sep 2024 14:04:23 +0800 Subject: [PATCH] Test reading empty zero-length file --- 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