Skip to content

Commit 12b775d

Browse files
committed
Allow empty header values
1 parent f758a19 commit 12b775d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

httplib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4115,7 +4115,7 @@ inline bool parse_header(const char *beg, const char *end, T fn) {
41154115
p++;
41164116
}
41174117

4118-
if (p < end) {
4118+
if (p <= end) {
41194119
auto key_len = key_end - beg;
41204120
if (!key_len) { return false; }
41214121

test/test.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4923,6 +4923,13 @@ TEST(ServerRequestParsingTest, InvalidFieldValueContains_CR_LF_NUL) {
49234923
EXPECT_EQ("HTTP/1.1 400 Bad Request", out.substr(0, 24));
49244924
}
49254925

4926+
TEST(ServerRequestParsingTest, EmptyFieldValue) {
4927+
std::string out;
4928+
4929+
test_raw_request("GET /header_field_value_check HTTP/1.1\r\nTest: \r\n", &out);
4930+
EXPECT_EQ("HTTP/1.1 200 OK", out.substr(0, 15));
4931+
}
4932+
49264933
TEST(ServerStopTest, StopServerWithChunkedTransmission) {
49274934
Server svr;
49284935

0 commit comments

Comments
 (0)