69 char curl_errbuf[CURL_ERROR_SIZE];
71 this->stream = stream;
72 curl = curl_easy_init();
73 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
74 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errbuf);
75 curl_easy_setopt(curl, CURLOPT_USERAGENT, GetUserAgent().c_str());
76 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
77 curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
79 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
80 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
81 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
82 curl_easy_setopt(curl, CURLOPT_WRITEDATA,
this);
83 curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
84 int code = curl_easy_perform(curl);
85 curl_easy_cleanup(curl);
86 if (code != CURLE_OK) {
87 wxLogWarning(
"Failed to get '%s' [%s]\n", url, curl_errbuf);
89 error_msg = std::string(curl_errbuf);
113 char curl_errbuf[CURL_ERROR_SIZE] = {0};
114 double filesize = 0.0;
116 curl = curl_easy_init();
117 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
118 curl_easy_setopt(curl, CURLOPT_USERAGENT, GetUserAgent().c_str());
119 curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
120 curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
121 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, throw_cb);
122 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
123 curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
125 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
127 int r = curl_easy_perform(curl);
129 r = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize);
131 curl_easy_cleanup(curl);
132 wxLogMessage(
"filesize %s: %d bytes\n", url.c_str(), (
int)filesize);
135 error_msg = std::string(curl_errbuf);
138 return (
long)filesize;
bool replace(std::string &str, const std::string &from, const std::string &to)
Perform in place substitution in str, replacing "from" with "to".