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

Method get

android/samples/fiber/http/src/main/cpp/http_get.cpp:14–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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