68 char curl_errbuf[CURL_ERROR_SIZE];
70 this->stream = stream;
71 curl = curl_easy_init();
72 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
73 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errbuf);
74 curl_easy_setopt(curl, CURLOPT_USERAGENT, GetUserAgent().c_str());
75 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
76 curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
78 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
79 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
80 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
81 curl_easy_setopt(curl, CURLOPT_WRITEDATA,
this);
82 curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
83 int code = curl_easy_perform(curl);
84 curl_easy_cleanup(curl);
85 if (code != CURLE_OK) {
86 wxLogWarning(
"Failed to get '%s' [%s]\n", url, curl_errbuf);
88 error_msg = std::string(curl_errbuf);
112 char curl_errbuf[CURL_ERROR_SIZE] = {0};
113 double filesize = 0.0;
115 curl = curl_easy_init();
116 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
117 curl_easy_setopt(curl, CURLOPT_USERAGENT, GetUserAgent().c_str());
118 curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
119 curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
120 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, throw_cb);
121 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
122 curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
124 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
126 int r = curl_easy_perform(curl);
128 r = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize);
130 curl_easy_cleanup(curl);
131 wxLogMessage(
"filesize %s: %d bytes\n", url.c_str(), (
int)filesize);
134 error_msg = std::string(curl_errbuf);
137 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".