Skip to content

Commit

Permalink
Allow empty header values
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-park committed Oct 18, 2024
1 parent 0cc1ca9 commit b2e329e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
9 changes: 9 additions & 0 deletions test/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit b2e329e

Please sign in to comment.