comparison Core/HttpClient.cpp @ 1590:ba0226474e22

New configuration option: "HttpTimeout" to set the default timeout for HTTP requests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 Aug 2015 17:51:03 +0200
parents 95b3b0260240
children 31f4adefb88f
comparison
equal deleted inserted replaced
1589:334d3a92ed83 1590:ba0226474e22
42 #include <boost/algorithm/string/predicate.hpp> 42 #include <boost/algorithm/string/predicate.hpp>
43 43
44 44
45 static std::string globalCACertificates_; 45 static std::string globalCACertificates_;
46 static bool globalVerifyPeers_ = true; 46 static bool globalVerifyPeers_ = true;
47 static long globalTimeout_ = 0;
47 48
48 extern "C" 49 extern "C"
49 { 50 {
50 static CURLcode GetHttpStatus(CURLcode code, CURL* curl, long* status) 51 static CURLcode GetHttpStatus(CURLcode code, CURL* curl, long* status)
51 { 52 {
138 139
139 url_ = ""; 140 url_ = "";
140 method_ = HttpMethod_Get; 141 method_ = HttpMethod_Get;
141 lastStatus_ = HttpStatus_200_Ok; 142 lastStatus_ = HttpStatus_200_Ok;
142 isVerbose_ = false; 143 isVerbose_ = false;
143 timeout_ = 0; 144 timeout_ = globalTimeout_;
144 verifyPeers_ = globalVerifyPeers_; 145 verifyPeers_ = globalVerifyPeers_;
145 } 146 }
146 147
147 148
148 HttpClient::HttpClient() : pimpl_(new PImpl) 149 HttpClient::HttpClient() : pimpl_(new PImpl)
382 383
383 void HttpClient::GlobalFinalize() 384 void HttpClient::GlobalFinalize()
384 { 385 {
385 curl_global_cleanup(); 386 curl_global_cleanup();
386 } 387 }
388
389
390 void HttpClient::SetDefaultTimeout(long timeout)
391 {
392 LOG(INFO) << "Setting the default timeout for HTTP client connections: " << timeout << " seconds";
393 globalTimeout_ = timeout;
394 }
387 } 395 }