forked from archibate/co_http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_client.cpp
More file actions
37 lines (32 loc) · 1.07 KB
/
sample_client.cpp
File metadata and controls
37 lines (32 loc) · 1.07 KB
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
33
34
35
36
37
#include "io_context.hpp"
#include "http_client.hpp"
void client() {
io_context ctx;
auto client = http_client::make();
client->do_request(
{"GET", "http://142857.red"},
[client](expected<int> ret,
http_client::http_response const &response) {
ret.expect("http://142857.red");
// fmt::println("{}", response.body);
io_context::get().set_timeout(std::chrono::seconds(1), [client] {
client->do_request(
{"GET", "http://142857.red"},
[client](expected<int> ret,
http_client::http_response const &response) {
ret.expect("http://142857.red");
// fmt::println("{}", response.body);
});
});
});
ctx.join();
}
int main() {
// try {
client();
// } catch (std::system_error const &e) {
// fmt::println("{} ({}/{})", e.what(), e.code().category().name(),
// e.code().value());
// }
return 0;
}