| 12 | {} |
| 13 | |
| 14 | bool 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 | |
| 43 | void http_get::run(void) { |
| 44 | log_info("http_get(%d): host=%s, port=%d, url=%s", __LINE__, |
nothing calls this directly
no test coverage detected