pictureviewer.cpp: CPictureViewer::DownloadImage add curl timeout opt

Origin commit data
------------------
Commit: 1121e6210e
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2015-02-04 (Wed, 04 Feb 2015)
This commit is contained in:
Jacek Jendrzej
2015-02-04 15:35:13 +01:00
parent 77aec57555
commit 2a86d6f32e

View File

@@ -111,6 +111,8 @@ std::string CPictureViewer::DownloadImage(std::string url)
FILE *tmpFile = fopen(tmpname.c_str(), "wb");
if (tmpFile) {
CURL *ch = curl_easy_init();
if(ch)
{
curl_easy_setopt(ch, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(ch, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L);
@@ -118,8 +120,15 @@ std::string CPictureViewer::DownloadImage(std::string url)
curl_easy_setopt(ch, CURLOPT_WRITEDATA, tmpFile);
curl_easy_setopt(ch, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(ch, CURLOPT_URL, url.c_str());
curl_easy_perform(ch);
curl_easy_setopt(ch, CURLOPT_NOSIGNAL,1);
curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_easy_setopt(ch, CURLOPT_TIMEOUT, 4);
CURLcode res = curl_easy_perform(ch);
if (res != CURLE_OK){
printf("[%s] curl_easy_perform() failed:%s\n",__func__, curl_easy_strerror(res));
}
curl_easy_cleanup(ch);
}
fclose(tmpFile);
url = true;
}