| 184 | } |
| 185 | |
| 186 | static bool configureCURL(CURL *handle, CAHttpClient* httpClient) |
| 187 | { |
| 188 | if (!handle) { |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | int32_t code; |
| 193 | code = curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, httpClient->s_errorBuffer); |
| 194 | if (code != CURLE_OK) { |
| 195 | return false; |
| 196 | } |
| 197 | code = curl_easy_setopt(handle, CURLOPT_TIMEOUT, CAHttpClient::getInstance()->getTimeoutForRead()); |
| 198 | if (code != CURLE_OK) { |
| 199 | return false; |
| 200 | } |
| 201 | code = curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, CAHttpClient::getInstance()->getTimeoutForConnect()); |
| 202 | if (code != CURLE_OK) { |
| 203 | return false; |
| 204 | } |
| 205 | code = curl_easy_setopt(handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); |
| 206 | if (code != CURLE_OK) { |
| 207 | return false; |
| 208 | } |
| 209 | if (httpClient->_sslCaFilename.empty()) |
| 210 | { |
| 211 | curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L); |
| 212 | curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L); |
| 213 | } |
| 214 | else |
| 215 | { |
| 216 | curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1L); |
| 217 | curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 2L); |
| 218 | curl_easy_setopt(handle, CURLOPT_CAINFO, httpClient->_sslCaFilename.c_str()); |
| 219 | } |
| 220 | |
| 221 | curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L); |
| 222 | |
| 223 | return true; |
| 224 | } |
| 225 | |
| 226 | class CURLRaii |
| 227 | { |