| 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 |
nothing calls this directly
no test coverage detected