MCPcopy Create free account
hub / github.com/acl-dev/acl / http_client

Function http_client

lib_fiber/samples-c++/https_client/main.cpp:23–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21static acl::string __host;
22
23static void http_client(ACL_FIBER *fiber, const char* addr)
24{
25 acl::string body;
26 acl::http_request req(addr, __conn_timeout, __rw_timeout);
27 acl::http_header& hdr = req.request_header();
28
29 acl::istream::set_rbuf_size(20480);
30
31 req.set_ssl(__ssl_conf);
32
33 for (int i = 0; i < __max_loop; i++) {
34 hdr.set_url("/")
35 .set_content_type("text/plain")
36 .set_keep_alive(true);
37 if (!__host.empty()) {
38 hdr.set_host(__host);
39 }
40
41 if (i == 0) {
42 acl::string hdrbuf;
43 hdr.build_request(hdrbuf);
44 printf("request header:\r\n%s\r\n", hdrbuf.c_str());
45 }
46 if (!req.request(NULL, 0)) {
47 printf("send request error\r\n");
48 break;
49 }
50
51 if (!req.get_body(body)) {
52 printf("get_body error\r\n");
53 break;
54 }
55
56 if (i < 1) {
57 if (body.size() < 1000) {
58 printf(">>>fiber-%d: body: %s\r\n",
59 acl_fiber_id(fiber), body.c_str());
60 } else {
61 printf(">>>fiber-%d: body len: %zd\r\n",
62 acl_fiber_id(fiber), body.size());
63 }
64 }
65
66 __total_count++;
67 body.clear();
68 req.reset();
69 }
70}
71
72static void fiber_client(ACL_FIBER *fiber, void *ctx)
73{

Callers 1

fiber_clientFunction · 0.70

Calls 13

request_headerMethod · 0.80
set_keep_aliveMethod · 0.80
set_content_typeMethod · 0.80
acl_fiber_idFunction · 0.50
set_sslMethod · 0.45
emptyMethod · 0.45
build_requestMethod · 0.45
c_strMethod · 0.45
requestMethod · 0.45
get_bodyMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…