rework client using async api
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user