lib/curl/Easy: use pass std::chrono::duration to SetTimeout()
This commit is contained in:
parent
7c21d57953
commit
13576b8a2e
@ -138,7 +138,7 @@ static const char *cacert;
|
|||||||
static bool verify_peer, verify_host;
|
static bool verify_peer, verify_host;
|
||||||
|
|
||||||
/** Connection settings */
|
/** Connection settings */
|
||||||
static long connect_timeout;
|
static std::chrono::duration<long> connect_timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CURLOPT_VERBOSE - verbose mode
|
* CURLOPT_VERBOSE - verbose mode
|
||||||
@ -406,10 +406,11 @@ input_curl_init(EventLoop &event_loop, const ConfigBlock &block)
|
|||||||
verify_peer = block.GetBlockValue("verify_peer", default_verify);
|
verify_peer = block.GetBlockValue("verify_peer", default_verify);
|
||||||
verify_host = block.GetBlockValue("verify_host", default_verify);
|
verify_host = block.GetBlockValue("verify_host", default_verify);
|
||||||
|
|
||||||
constexpr unsigned default_connection_timeout = 10;
|
constexpr std::chrono::seconds default_connection_timeout{10};
|
||||||
unsigned timeout = block.GetBlockValue("connect_timeout",
|
connect_timeout = std::chrono::duration_cast<std::chrono::duration<long>>(
|
||||||
default_connection_timeout);
|
block.GetDuration("connect_timeout",
|
||||||
connect_timeout = static_cast<long>(timeout);
|
std::chrono::seconds{1},
|
||||||
|
default_connection_timeout));
|
||||||
|
|
||||||
verbose = block.GetBlockValue("verbose",verbose);
|
verbose = block.GetBlockValue("verbose",verbose);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -139,12 +140,12 @@ public:
|
|||||||
SetOption(CURLOPT_PROXY_SSL_VERIFYPEER, value);
|
SetOption(CURLOPT_PROXY_SSL_VERIFYPEER, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetConnectTimeout(long timeout) {
|
void SetConnectTimeout(std::chrono::duration<long> timeout) {
|
||||||
SetOption(CURLOPT_CONNECTTIMEOUT, timeout);
|
SetOption(CURLOPT_CONNECTTIMEOUT, timeout.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTimeout(long timeout) {
|
void SetTimeout(std::chrono::duration<long> timeout) {
|
||||||
SetOption(CURLOPT_TIMEOUT, timeout);
|
SetOption(CURLOPT_TIMEOUT, timeout.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetHeaderFunction(size_t (*function)(char *buffer, size_t size,
|
void SetHeaderFunction(size_t (*function)(char *buffer, size_t size,
|
||||||
|
@ -16,7 +16,7 @@ Setup(CurlEasy &easy)
|
|||||||
#endif
|
#endif
|
||||||
easy.SetNoProgress();
|
easy.SetNoProgress();
|
||||||
easy.SetNoSignal();
|
easy.SetNoSignal();
|
||||||
easy.SetConnectTimeout(10);
|
easy.SetConnectTimeout(std::chrono::seconds{10});
|
||||||
easy.SetOption(CURLOPT_HTTPAUTH, (long) CURLAUTH_ANY);
|
easy.SetOption(CURLOPT_HTTPAUTH, (long) CURLAUTH_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user