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

Method url_get

harmony/api9/acl_one/entry/src/main/cpp/hello.cpp:30–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 bool url_get() {
31 const char* addr = "www.baidu.com:80";
32 acl::http_request req(addr, 5);
33 req.request_header().set_url("/")
34 .set_host("www.baidu.com");
35
36 if (!req.request(nullptr, 0)) {
37 log_info("%s: http request error, addr=%s", __func__, addr);
38 return false;
39 }
40
41 int http_status = req.http_status();
42 acl::string buf;
43 buf.format("http status=%d", http_status);
44 log_info( "%s: url_get", __func__, buf.c_str());
45
46 if (!req.get_body(body_)) {
47 log_error("%s: get http body error!", __func__);
48 return false;
49 }
50
51 req.get_client()->sprint_header(head_);
52 log_info("%s: http response body: %s", __func__, body_.c_str());
53 return true;
54 }
55};
56
57static napi_value HttpGet(napi_env env, napi_callback_info info)

Callers

nothing calls this directly

Calls 10

request_headerMethod · 0.80
http_statusMethod · 0.80
log_infoFunction · 0.70
log_errorFunction · 0.70
requestMethod · 0.45
formatMethod · 0.45
c_strMethod · 0.45
get_bodyMethod · 0.45
sprint_headerMethod · 0.45
get_clientMethod · 0.45

Tested by

no test coverage detected