Mercurial > hg > orthanc
diff Core/HttpClient.cpp @ 1186:b17b6bd59747
timeouts for HTTP and DICOM
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 14 Oct 2014 14:47:58 +0200 |
parents | cc4ff680e2a0 |
children | 88010d8e12cf |
line wrap: on
line diff
--- a/Core/HttpClient.cpp Fri Oct 10 09:13:48 2014 +0200 +++ b/Core/HttpClient.cpp Tue Oct 14 14:47:58 2014 +0200 @@ -109,6 +109,7 @@ method_ = HttpMethod_Get; lastStatus_ = HttpStatus_200_Ok; isVerbose_ = false; + timeout_ = 0; } @@ -171,6 +172,18 @@ CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDS, NULL)); CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDSIZE, 0)); + // Set timeouts + if (timeout_ <= 0) + { + CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_TIMEOUT, 10)); /* default: 10 seconds */ + CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CONNECTTIMEOUT, 10)); /* default: 10 seconds */ + } + else + { + CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_TIMEOUT, timeout_)); + CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CONNECTTIMEOUT, timeout_)); + } + if (credentials_.size() != 0) { CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_USERPWD, credentials_.c_str()));