Fix URL encoding issues; remove request shortcuts.

This commit is contained in:
Chunting Gu
2019-08-23 14:51:41 +08:00
parent 9b31ac855a
commit 1a21989b2e
16 changed files with 372 additions and 365 deletions
+6 -15
View File
@@ -14,22 +14,14 @@ int main() {
try {
r = session.Request(webcc::RequestBuilder{}.
Get("http://httpbin.org/get").
Query("key1", "value1").
Query("key2", "value2").
Date().
Header("Accept", "application/json")
Query("name", "Adam Gu", /*encode*/true).
Header("Accept", "application/json").
Date()
());
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}").
@@ -41,7 +33,9 @@ int main() {
#if WEBCC_ENABLE_SSL
r = session.Get("https://httpbin.org/get");
r = session.Request(webcc::RequestBuilder{}.
Get("https://httpbin.org/get")
());
assert(r->status() == webcc::Status::kOK);
assert(!r->data().empty());
@@ -51,9 +45,6 @@ int main() {
} catch (const webcc::Error& error) {
std::cerr << error << std::endl;
return 1;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
}
return 0;