-
Notifications
You must be signed in to change notification settings - Fork 2
/
sample.cc
32 lines (26 loc) · 887 Bytes
/
sample.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <cassert>
#include <iostream>
#include <string>
#include "flow.hpp"
int main( int argc, const char **argv ) {
auto prompt = []() {
std::string prompt;
while( prompt.empty() ) {
std::cout << "url> ";
std::getline( std::cin, prompt );
}
return prompt;
};
for( ;; ) {
std::string url;
url = prompt();
// sync test
flow::status status = flow::download(url);
std::cout << "sync: "<< status.url << ";ok=" << status.ok << "," << status.data.size() << " bytes;" << status.code << std::endl;
// async test
flow::download_async(url, []( flow::status &status ) {
std::cout << "async: "<< status.url << ";ok=" << status.ok << "," << status.data.size() << " bytes;" << status.code << std::endl;
} );
}
return 0;
}