Refine the connection close

This commit is contained in:
Chunting Gu
2019-07-15 15:36:30 +08:00
parent 2a20030f7e
commit 46ea52cb90
24 changed files with 214 additions and 147 deletions
+13 -2
View File
@@ -1,3 +1,4 @@
#include <cassert>
#include <iostream>
#include "webcc/client_session.h"
@@ -11,8 +12,6 @@ int main() {
webcc::ResponsePtr r;
try {
r = session.Head("http://httpbin.org/get");
r = session.Request(webcc::RequestBuilder{}.
Get("http://httpbin.org/get").
Query("key1", "value1").
@@ -21,20 +20,32 @@ int main() {
Header("Accept", "application/json")
());
assert(r->status() == webcc::Status::kOK);
assert(!r->data().empty());
r = session.Get("http://httpbin.org/get",
{ "key1", "value1", "key2", "value2" },
{ "Accept", "application/json" });
assert(r->status() == webcc::Status::kOK);
assert(!r->data().empty());
r = session.Request(webcc::RequestBuilder{}.
Post("http://httpbin.org/post").
Body("{'name'='Adam', 'age'=20}").
Json().Utf8()
());
assert(r->status() == webcc::Status::kOK);
assert(!r->data().empty());
#if WEBCC_ENABLE_SSL
r = session.Get("https://httpbin.org/get");
assert(r->status() == webcc::Status::kOK);
assert(!r->data().empty());
#endif // WEBCC_ENABLE_SSL
} catch (const webcc::Error& error) {