| 97 | } |
| 98 | |
| 99 | bool http_get_binary(const char *url, const uint8_t *buf, size_t *size) |
| 100 | { |
| 101 | assert(s_curl_handle && "http_init wasn't called"); |
| 102 | assert(url && "invalid url"); |
| 103 | assert(buf && size); |
| 104 | http_recv_buf tmp = { *size, 0, buf }; |
| 105 | LOG_INFO("Downloading %s", url); |
| 106 | CURL *curl = curl_easy_duphandle(s_curl_handle); |
| 107 | assert(curl); |
| 108 | if (s_agentName) |
| 109 | DO_CURL(setopt(curl, CURLOPT_USERAGENT, s_agentName)); |
| 110 | DO_CURL(setopt(curl, CURLOPT_SSL_VERIFYPEER, 0)); |
| 111 | DO_CURL(setopt(curl, CURLOPT_FOLLOWLOCATION, 1)); |
| 112 | DO_CURL(setopt(curl, CURLOPT_URL, url)); |
| 113 | DO_CURL(setopt(curl, CURLOPT_WRITEDATA, &tmp)); |
| 114 | DO_CURL(setopt(curl, CURLOPT_WRITEFUNCTION, recv_data)); |
| 115 | CURLcode result; |
| 116 | DO_CURL_RET(result, perform(curl)); |
| 117 | curl_easy_cleanup(curl); |
| 118 | *size = tmp.offset; |
| 119 | return result == CURLE_OK; |
| 120 | } |
| 121 | |
| 122 | bool http_get_binary(const char *url, std::vector<uint8_t> &data) |
| 123 | { |
no test coverage detected