MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / fetchURL

Method fetchURL

src/curl_wrapper.cpp:86–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 }
85
86 virtual string fetchURL(const string& url) {
87 string data;
88
89 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, &CurlData);
90 curl_easy_setopt(handle, CURLOPT_WRITEDATA, &data);
91 curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
92
93 CURLcode rv = curl_easy_perform(handle);
94 if (rv != CURLE_OK)
95 throw curl_error(url, curl_easy_strerror(rv));
96
97 long httpCode;
98 rv = curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &httpCode);
99 if (rv != CURLE_OK)
100 throw curl_error(url, curl_easy_strerror(rv));
101 if (httpCode != 200)
102 throw curl_error(url, statusCodeErrorStr(httpCode));
103
104 return data;
105 }
106
107 virtual CURL* getHandle() { return handle; }
108

Callers

nothing calls this directly

Calls 2

curl_errorClass · 0.85
statusCodeErrorStrFunction · 0.85

Tested by

no test coverage detected