Added HEAD method support.

This commit is contained in:
yhirose 2012-10-12 17:41:58 -04:00
parent 448a7f4f11
commit b5ae7d0e7a
2 changed files with 44 additions and 17 deletions

View file

@ -15,7 +15,7 @@ using namespace std;
using namespace httplib;
const char* HOST = "localhost";
const int PORT = 8080;
const int PORT = 1234;
class thread
{
@ -260,6 +260,23 @@ TEST_F(ServerTest, GetMethod404)
EXPECT_EQ(404, res->status);
}
TEST_F(ServerTest, HeadMethod200)
{
auto res = cli_.head("/hi");
ASSERT_TRUE(res != nullptr);
EXPECT_EQ(200, res->status);
EXPECT_EQ("text/plain", res->get_header_value("Content-Type"));
EXPECT_EQ("", res->body);
}
TEST_F(ServerTest, HeadMethod404)
{
auto res = cli_.head("/invalid");
ASSERT_TRUE(res != nullptr);
EXPECT_EQ(404, res->status);
EXPECT_EQ("", res->body);
}
TEST_F(ServerTest, GetMethodPersonJohn)
{
auto res = cli_.get("/person/john");