diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2018-05-04 13:45:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-04 13:45:19 +0200 |
| commit | 00de41b583374c68aee651ba44aec886d48fd39f (patch) | |
| tree | 8fbc3866a78b9bee965130633bd5f47afa2456f3 /Source/Core | |
| parent | a5e410b7c9e07ab7d34e465c27c0f783a3b09675 (diff) | |
| parent | 11f83c1e369d3028e53b307575691d9eaf82a32c (diff) | |
Merge pull request #6748 from spycrab/curl_timeout
HttpRequest/Curl: Use a more intelligent timeout method
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/HttpRequest.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Source/Core/Common/HttpRequest.cpp b/Source/Core/Common/HttpRequest.cpp index edb3286b19..ff8fa32c2e 100644 --- a/Source/Core/Common/HttpRequest.cpp +++ b/Source/Core/Common/HttpRequest.cpp @@ -108,7 +108,12 @@ HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback c // libcurl may not have been built with async DNS support, so we disable // signal handlers to avoid a possible and likely crash if a resolve times out. curl_easy_setopt(m_curl.get(), CURLOPT_NOSIGNAL, true); - curl_easy_setopt(m_curl.get(), CURLOPT_TIMEOUT_MS, static_cast<long>(timeout_ms.count())); + curl_easy_setopt(m_curl.get(), CURLOPT_CONNECTTIMEOUT_MS, static_cast<long>(timeout_ms.count())); + // Sadly CURLOPT_LOW_SPEED_TIME doesn't have a millisecond variant so we have to use seconds + curl_easy_setopt( + m_curl.get(), CURLOPT_LOW_SPEED_TIME, + static_cast<long>(std::chrono::duration_cast<std::chrono::seconds>(timeout_ms).count())); + curl_easy_setopt(m_curl.get(), CURLOPT_LOW_SPEED_LIMIT, 1); #ifdef _WIN32 // ALPN support is enabled by default but requires Windows >= 8.1. curl_easy_setopt(m_curl.get(), CURLOPT_SSL_ENABLE_ALPN, false); |
