MCPcopy Create free account
hub / github.com/crossuo/crossuo / http_get_binary

Function http_get_binary

xuocore/http.cpp:99–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99bool 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
122bool http_get_binary(const char *url, std::vector<uint8_t> &data)
123{

Callers 4

xuo_changelog_loadFunction · 0.85
xuo_manifest_loadFunction · 0.85
mft_downloadFunction · 0.85
xuoi_product_installFunction · 0.85

Calls 2

curl_easy_duphandleFunction · 0.85
curl_easy_cleanupFunction · 0.85

Tested by

no test coverage detected