lib/curl/Easy: use pass std::chrono::duration to SetTimeout()

This commit is contained in:
Max Kellermann
2024-07-10 14:20:52 +02:00
committed by Max Kellermann
parent 7c21d57953
commit 13576b8a2e
3 changed files with 12 additions and 10 deletions

View File

@@ -8,6 +8,7 @@
#include <curl/curl.h>
#include <chrono>
#include <cstddef>
#include <span>
#include <stdexcept>
@@ -139,12 +140,12 @@ public:
SetOption(CURLOPT_PROXY_SSL_VERIFYPEER, value);
}
void SetConnectTimeout(long timeout) {
SetOption(CURLOPT_CONNECTTIMEOUT, timeout);
void SetConnectTimeout(std::chrono::duration<long> timeout) {
SetOption(CURLOPT_CONNECTTIMEOUT, timeout.count());
}
void SetTimeout(long timeout) {
SetOption(CURLOPT_TIMEOUT, timeout);
void SetTimeout(std::chrono::duration<long> timeout) {
SetOption(CURLOPT_TIMEOUT, timeout.count());
}
void SetHeaderFunction(size_t (*function)(char *buffer, size_t size,

View File

@@ -16,7 +16,7 @@ Setup(CurlEasy &easy)
#endif
easy.SetNoProgress();
easy.SetNoSignal();
easy.SetConnectTimeout(10);
easy.SetConnectTimeout(std::chrono::seconds{10});
easy.SetOption(CURLOPT_HTTPAUTH, (long) CURLAUTH_ANY);
}