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

Method get

android/samples/fiber/HttpFiber/src/main/cpp/http_get.cpp:15–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13{}
14
15bool http_get::get(const char* addr, const char* host,
16 const char *url, acl::string &out) {
17 acl::http_request request(addr);
18 acl::http_header& header = request.request_header();
19
20 header.set_url(url)
21 .set_host(host)
22 .accept_gzip(true)
23 .set_keep_alive(false);
24
25 log_info("http_get(%d): addr=%s, host=%s, url=%s", __LINE__, addr, host, url);
26
27 if (!request.request(NULL, 0)) {
28 log_error("send http request error=%s", acl::last_serror());
29 return false;
30 }
31
32 if (!request.get_body(out)) {
33 log_error("get body error: %s", acl::last_serror());
34 return false;
35 }
36
37 acl::http_client* conn = request.get_client();
38 acl::string hdr_res;
39 conn->sprint_header(hdr_res, "response header");
40 log_info("%s", hdr_res.c_str());
41 return true;
42}
43
44void http_get::run(void) {
45 std::vector<acl::string> ips;

Callers

nothing calls this directly

Calls 11

request_headerMethod · 0.80
set_keep_aliveMethod · 0.80
accept_gzipMethod · 0.80
log_infoFunction · 0.70
log_errorFunction · 0.70
last_serrorFunction · 0.50
requestMethod · 0.45
get_bodyMethod · 0.45
get_clientMethod · 0.45
sprint_headerMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected