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

Function main

lib_acl_cpp/samples/http/http_request/main.cpp:13–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13int main(int argc, char* argv[])
14{
15 int ch, max = 10;
16 bool accept_gzip = false, send_body = false;
17 acl::string addr("127.0.0.1:8194");
18
19 acl::acl_cpp_init();
20
21 while ((ch = getopt(argc, argv, "hs:n:zB")) > 0)
22 {
23 switch (ch)
24 {
25 case 'h':
26 usage(argv[0]);
27 return 0;
28 case 's':
29 addr = optarg;
30 break;
31 case 'n':
32 max = atoi(optarg);
33 break;
34 case 'z':
35 accept_gzip = true;
36 break;
37 case 'B':
38 send_body = true;
39 break;
40 default:
41 break;
42 }
43 }
44
45 acl::log::stdout_open(true);
46
47 acl::string buf(1024);
48 for (size_t i = 0; i < 1024; i++)
49 buf << 'X';
50
51 acl::http_request req(addr, 10, 10);
52 acl::string tmp(1024);
53
54 for (int i = 0; i < max; i++)
55 {
56 acl::http_header& header = req.request_header();
57 //header.set_method(acl::HTTP_METHOD_POST);
58 header.set_url("/");
59 header.set_keep_alive(true);
60 header.accept_gzip(accept_gzip ? true : false);
61 //header.set_content_length(buf.length());
62
63 bool rc;
64
65 if (send_body)
66 rc = req.request(buf.c_str(), buf.length());
67 else
68 rc = req.request(NULL, 0);
69
70 // 只所以将 build_request 放在 req.request 后面,是因为

Callers

nothing calls this directly

Calls 12

acl_cpp_initFunction · 0.85
request_headerMethod · 0.80
set_keep_aliveMethod · 0.80
accept_gzipMethod · 0.80
usageFunction · 0.70
getoptFunction · 0.50
requestMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
build_requestMethod · 0.45
clearMethod · 0.45
read_bodyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…