Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
mkcurl.hpp: use zero (= infinite) as default timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed May 28, 2019
1 parent 122433d commit 260c347
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mkcurl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ struct Request {
/// body contains the request body (possibly a binary body).
std::string body;

/// timeout is the time after which the request is aborted (in seconds)
int64_t timeout = 30;
/// timeout is the time after which the request is aborted (in seconds). A
/// value of zero means that no timeout is implemented.
int64_t timeout = 0;

/// proxy_url is the optional URL of the proxy to use.
std::string proxy_url;
Expand Down Expand Up @@ -538,10 +539,9 @@ Response perform(const Request &req) noexcept {
return res;
}
}
if (req.timeout >= 0) {
long t = 0L;
// Implementation note: `0L` means infinite for CURLOPT_TIMEOUT.
if (req.timeout > 0 && req.timeout < LONG_MAX) t = (long)req.timeout;
{
long t = 0L; // Note: `0L` means "infinite" for CURLOPT_TIMEOUT.
if (req.timeout >= 0 && req.timeout < LONG_MAX) t = (long)req.timeout;
res.error = curl_easy_setopt(handle.get(), CURLOPT_TIMEOUT, t);
MKCURL_HOOK(curl_easy_setopt_CURLOPT_TIMEOUT, res.error);
if (res.error != CURLE_OK) {
Expand Down

0 comments on commit 260c347

Please sign in to comment.