|
@@ -10,7 +10,8 @@
|
|
|
|
|
|
|
|
namespace Http {
|
|
namespace Http {
|
|
|
|
|
|
|
|
-HttpClientImpl::HttpClientImpl()
|
|
|
|
|
|
|
+HttpClientImpl::HttpClientImpl(int timeout) :
|
|
|
|
|
+ m_timeout(timeout)
|
|
|
{
|
|
{
|
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
|
|
|
|
|
@@ -207,6 +208,7 @@ std::string HttpClientImpl::GetUrlPostAttachmentContents(const std::string& url,
|
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
|
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, m_timeout);
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &WriteCallback);
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &WriteCallback);
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
@@ -285,6 +287,7 @@ void HttpClientImpl::GetUrlPostAttachmentSilent(const std::string& url, const st
|
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
|
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, m_timeout);
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
|
|
|
|
|
|
int code = 0;
|
|
int code = 0;
|
|
@@ -358,6 +361,7 @@ std::string HttpClientImpl::GetUrlPostAttachmentRedirect(const std::string& url,
|
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
|
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, m_timeout);
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
|
|
|
|
|
|
int code = 0;
|
|
int code = 0;
|
|
@@ -447,6 +451,7 @@ std::string HttpClientImpl::GetUrlPostAttachmentContents(const std::string& url,
|
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
|
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, m_timeout);
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
|
|
@@ -527,6 +532,7 @@ void HttpClientImpl::GetUrlPostAttachmentSilent(const std::string& url, const st
|
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
|
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, m_timeout);
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
|
|
@@ -602,6 +608,7 @@ std::string HttpClientImpl::GetUrlPostAttachmentRedirect(const std::string& url,
|
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
headerlist = curl_slist_append(headerlist, headerBuffer);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
|
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, m_timeout);
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookieFile.c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookieFile.c_str());
|
|
@@ -647,6 +654,7 @@ std::string HttpClientImpl::PerformOperation(HttpClientImpl::Operation::type typ
|
|
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
curl_easy_setopt(curl, CURLOPT_USERAGENT, m_userAgents[rand() % m_userAgents.size()].c_str());
|
|
curl_easy_setopt(curl, CURLOPT_USERAGENT, m_userAgents[rand() % m_userAgents.size()].c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
|
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, m_timeout);
|
|
|
|
|
|
|
|
if (type == HttpClientImpl::Operation::Silent)
|
|
if (type == HttpClientImpl::Operation::Silent)
|
|
|
{
|
|
{
|