update 2023-10-31 16:22:28

This commit is contained in:
github-actions[bot]
2023-10-31 16:22:28 +08:00
parent 6170b6adb5
commit 3a652d7190
10 changed files with 97 additions and 22 deletions

View File

@@ -69,4 +69,19 @@ TEST(MemNCaseMemTest, UserAgentStrange) {
void *result = memncasemem(l, l_len, s, s_len);
EXPECT_EQ(result, (void *) l);
}
TEST(HttpProtocolTest, RealWorldRequests) {
const char* getPayload = "GET /index.html HTTP/1.1\r\nHost: example.com\r\n\r\n";
const char* postPayload = "POST /submit HTTP/1.1\r\nHost: example.com\r\n\r\n";
const char* optionsPayload = "OPTIONS /test HTTP/1.1\r\nHost: example.com\r\n\r\n";
EXPECT_TRUE(is_http_protocol(getPayload, strlen(getPayload))) << "GET method failed";
EXPECT_TRUE(is_http_protocol(postPayload, strlen(postPayload))) << "POST method failed";
EXPECT_TRUE(is_http_protocol(optionsPayload, strlen(optionsPayload))) << "OPTIONS method failed";
const char* invalidPayload = "INVALID string";
// Check that these cases return false
EXPECT_FALSE(is_http_protocol(invalidPayload, strlen(invalidPayload))) << "Invalid method passed";
}