Fix payload iteration issue of FormBody; Log form body; ignore body for response of HEAD.

This commit is contained in:
Chunting Gu
2019-07-09 13:18:55 +08:00
parent 3309e7896a
commit b2cbc450b8
21 changed files with 364 additions and 165 deletions
+26 -4
View File
@@ -33,10 +33,7 @@ TEST(ClientTest, Head_RequestFunc) {
try {
auto r = session.Request(webcc::RequestBuilder{}.
Head("http://httpbin.org/get").
Query("key1", "value1").
Query("key2", "value2").
Header("Accept", "application/json")
Head("http://httpbin.org/get")
());
EXPECT_EQ(webcc::Status::kOK, r->status());
@@ -65,6 +62,31 @@ TEST(ClientTest, Head_Shortcut) {
}
}
// Force Accept-Encoding to be "identity" so that HttpBin.org will include
// a Content-Length header in the response.
// This tests that the response with Content-Length while no body could be
// correctly parsed.
TEST(ClientTest, Head_AcceptEncodingIdentity) {
webcc::ClientSession session;
try {
auto r = session.Request(webcc::RequestBuilder{}.
Head("http://httpbin.org/get").
Header("Accept-Encoding", "identity")
());
EXPECT_EQ(webcc::Status::kOK, r->status());
EXPECT_EQ("OK", r->reason());
EXPECT_TRUE(r->HasHeader(webcc::headers::kContentLength));
EXPECT_EQ("", r->data());
} catch (const webcc::Error& error) {
std::cerr << error << std::endl;
}
}
// -----------------------------------------------------------------------------
static void AssertGet(webcc::ResponsePtr r) {