HTTP parsing bug fixes, added tests
Fixed HTTP request parse failing if the URI was too short. Fixed HTTP parser not converting POST/GET data to lowercase before storing it, making post and get data which contained capitals impossible to access.
This commit is contained in:
@@ -185,4 +185,30 @@ TEST(HttpRequestTest, partial_parse)
|
||||
ASSERT_EQ(request.get_type(), fr::Http::Get);
|
||||
ASSERT_EQ(request.header("content-type"), "application/x-www-form-urlencoded");
|
||||
ASSERT_EQ(request.header("Cache-Control"), "no-cache");
|
||||
}
|
||||
|
||||
TEST(HttpRequestTest, awkward_parse)
|
||||
{
|
||||
std::string request_data = ""
|
||||
"POST /my/url? HTTP/1.1\n"
|
||||
"\n"
|
||||
"Test=bob\n"
|
||||
"\n";
|
||||
fr::HttpRequest request;
|
||||
ASSERT_EQ(request.parse(request_data.c_str(), request_data.size()), fr::Socket::Success);
|
||||
ASSERT_EQ(request.get_uri(), "/my/url");
|
||||
ASSERT_EQ(request.post("Test"), "bob");
|
||||
}
|
||||
|
||||
TEST(HttpRequestTest, awkward_parse2)
|
||||
{
|
||||
std::string request_data = "POST /my/url?Bob=10 HTTP/1.1\n"
|
||||
"\n"
|
||||
"Test=bob";
|
||||
|
||||
fr::HttpRequest request;
|
||||
ASSERT_EQ(request.parse(request_data.c_str(), request_data.size()), fr::Socket::Success);
|
||||
ASSERT_EQ(request.get_uri(), "/my/url");
|
||||
ASSERT_EQ(request.get("Bob"), "10");
|
||||
ASSERT_EQ(request.post("Test"), "bob");
|
||||
}
|
||||
Reference in New Issue
Block a user