rework client using async api

This commit is contained in:
Chunting Gu
2021-04-16 19:07:31 +08:00
parent 7f345b7a4e
commit f5210ba1a2
27 changed files with 855 additions and 522 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ int main() {
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
webcc::ClientSession session;
session.set_connect_timeout(5);
session.set_read_timeout(5);
session.Accept("application/json");
webcc::ResponsePtr r;
+1 -1
View File
@@ -30,7 +30,7 @@ int main(int argc, const char* argv[]) {
threads.emplace_back([&url]() {
// NOTE: Each thread has its own client session.
webcc::ClientSession session;
session.set_timeout(180);
session.set_read_timeout(180);
try {
LOG_USER("Start");
+4 -1
View File
@@ -27,7 +27,10 @@ int main(int argc, char* argv[]) {
webcc::ClientSession session;
try {
auto r = session.Send(webcc::RequestBuilder{}.Get(url)(), true);
auto r = session.Send(webcc::RequestBuilder{}.Get(url)(), true,
[](std::size_t length, std::size_t total_length) {
std::cout << "Progress " << length << " / " << total_length << std::endl;
});
if (auto file_body = r->file_body()) {
file_body->Move(path);