UI: Add timeout parameter to RemoteTextThread
Allows specifying a timeout for the operation.
This commit is contained in:
parent
4ba48484ae
commit
44834bbf04
@ -71,6 +71,10 @@ void RemoteTextThread::run()
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA,
|
||||
&str);
|
||||
|
||||
if (timeoutSec)
|
||||
curl_easy_setopt(curl.get(), CURLOPT_TIMEOUT,
|
||||
timeoutSec);
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x072400
|
||||
// A lot of servers don't yet support ALPN
|
||||
curl_easy_setopt(curl.get(), CURLOPT_SSL_ENABLE_ALPN, 0);
|
||||
@ -118,7 +122,8 @@ bool GetRemoteFile(
|
||||
const char *contentType,
|
||||
const char *postData,
|
||||
std::vector<std::string> extraHeaders,
|
||||
std::string *signature)
|
||||
std::string *signature,
|
||||
int timeoutSec)
|
||||
{
|
||||
vector<string> header_in_list;
|
||||
char error_in[CURL_ERROR_SIZE];
|
||||
@ -166,6 +171,10 @@ bool GetRemoteFile(
|
||||
&header_in_list);
|
||||
}
|
||||
|
||||
if (timeoutSec)
|
||||
curl_easy_setopt(curl.get(), CURLOPT_TIMEOUT,
|
||||
timeoutSec);
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x072400
|
||||
// A lot of servers don't yet support ALPN
|
||||
curl_easy_setopt(curl.get(), CURLOPT_SSL_ENABLE_ALPN, 0);
|
||||
|
@ -28,6 +28,8 @@ class RemoteTextThread : public QThread {
|
||||
std::string contentType;
|
||||
std::string postData;
|
||||
|
||||
int timeoutSec = 0;
|
||||
|
||||
void run() override;
|
||||
|
||||
signals:
|
||||
@ -37,8 +39,12 @@ public:
|
||||
inline RemoteTextThread(
|
||||
std::string url_,
|
||||
std::string contentType_ = std::string(),
|
||||
std::string postData_ = std::string())
|
||||
: url(url_), contentType(contentType_), postData(postData_)
|
||||
std::string postData_ = std::string(),
|
||||
int timeoutSec_ = 0)
|
||||
: url (url_),
|
||||
contentType (contentType_),
|
||||
postData (postData_),
|
||||
timeoutSec (timeoutSec_)
|
||||
{}
|
||||
};
|
||||
|
||||
@ -50,4 +56,5 @@ bool GetRemoteFile(
|
||||
const char *contentType = nullptr,
|
||||
const char *postData = nullptr,
|
||||
std::vector<std::string> extraHeaders = std::vector<std::string>(),
|
||||
std::string *signature = nullptr);
|
||||
std::string *signature = nullptr,
|
||||
int timeoutSec = 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user