Allow empty header values (#1965)
Some checks are pending
test / ubuntu (push) Waiting to run
test / macos (push) Waiting to run
test / windows (push) Waiting to run

This commit is contained in:
Jiwoo Park 2024-10-18 23:16:48 +09:00 committed by GitHub
parent 0cc1ca9a8d
commit d869054318
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -4115,7 +4115,7 @@ inline bool parse_header(const char *beg, const char *end, T fn) {
p++;
}
if (p < end) {
if (p <= end) {
auto key_len = key_end - beg;
if (!key_len) { return false; }

View file

@ -4922,6 +4922,15 @@ TEST(ServerRequestParsingTest, InvalidFieldValueContains_CR_LF_NUL) {
EXPECT_EQ("HTTP/1.1 400 Bad Request", out.substr(0, 24));
}
TEST(ServerRequestParsingTest, EmptyFieldValue) {
std::string out;
test_raw_request("GET /header_field_value_check HTTP/1.1\r\n"
"Test: \r\n\r\n",
&out);
EXPECT_EQ("HTTP/1.1 200 OK", out.substr(0, 15));
}
TEST(ServerStopTest, StopServerWithChunkedTransmission) {
Server svr;