1
0
mirror of synced 2025-04-20 11:47:43 +03:00
This commit is contained in:
yhirose 2025-03-10 23:31:51 -04:00
parent 5a1ecc3958
commit 48084d55f2
2 changed files with 11 additions and 0 deletions

View File

@ -4170,6 +4170,9 @@ inline bool parse_header(const char *beg, const char *end, T fn) {
p++;
}
auto name = std::string(beg, p);
if (!detail::fields::is_field_name(name)) { return false; }
if (p == end) { return false; }
auto key_end = p;

View File

@ -5156,6 +5156,14 @@ TEST(ServerRequestParsingTest, InvalidFieldValueContains_LF) {
EXPECT_EQ("HTTP/1.1 400 Bad Request", out.substr(0, 24));
}
TEST(ServerRequestParsingTest, InvalidFieldNameContains_PreceedingSpaces) {
std::string out;
std::string request(
"GET /header_field_value_check HTTP/1.1\r\n Test: val\r\n\r\n", 55);
test_raw_request(request, &out);
EXPECT_EQ("HTTP/1.1 400 Bad Request", out.substr(0, 24));
}
TEST(ServerRequestParsingTest, EmptyFieldValue) {
std::string out;