Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1184:4e9d517503ae | 1186:b17b6bd59747 |
---|---|
107 | 107 |
108 url_ = ""; | 108 url_ = ""; |
109 method_ = HttpMethod_Get; | 109 method_ = HttpMethod_Get; |
110 lastStatus_ = HttpStatus_200_Ok; | 110 lastStatus_ = HttpStatus_200_Ok; |
111 isVerbose_ = false; | 111 isVerbose_ = false; |
112 timeout_ = 0; | |
112 } | 113 } |
113 | 114 |
114 | 115 |
115 HttpClient::HttpClient() : pimpl_(new PImpl) | 116 HttpClient::HttpClient() : pimpl_(new PImpl) |
116 { | 117 { |
168 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POST, 0L)); | 169 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POST, 0L)); |
169 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_NOBODY, 0L)); | 170 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_NOBODY, 0L)); |
170 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CUSTOMREQUEST, NULL)); | 171 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CUSTOMREQUEST, NULL)); |
171 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDS, NULL)); | 172 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDS, NULL)); |
172 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDSIZE, 0)); | 173 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDSIZE, 0)); |
174 | |
175 // Set timeouts | |
176 if (timeout_ <= 0) | |
177 { | |
178 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_TIMEOUT, 10)); /* default: 10 seconds */ | |
179 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CONNECTTIMEOUT, 10)); /* default: 10 seconds */ | |
180 } | |
181 else | |
182 { | |
183 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_TIMEOUT, timeout_)); | |
184 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CONNECTTIMEOUT, timeout_)); | |
185 } | |
173 | 186 |
174 if (credentials_.size() != 0) | 187 if (credentials_.size() != 0) |
175 { | 188 { |
176 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_USERPWD, credentials_.c_str())); | 189 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_USERPWD, credentials_.c_str())); |
177 } | 190 } |