Skip to content

Commit

Permalink
Merge pull request #6748 from spycrab/curl_timeout
Browse files Browse the repository at this point in the history
HttpRequest/Curl: Use a more intelligent timeout method
  • Loading branch information
delroth committed May 4, 2018
2 parents a5e410b + 11f83c1 commit 00de41b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Source/Core/Common/HttpRequest.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 00de41b

Please sign in to comment.