UI: Add alternate constructor for RemoteTextThread

Allows specifying extra headers.
master
jp9000 2018-11-23 18:15:57 -08:00
parent 44834bbf04
commit 08e6dcd516
2 changed files with 18 additions and 0 deletions

View File

@ -61,6 +61,9 @@ void RemoteTextThread::run()
contentTypeString.c_str());
}
for (std::string &h : extraHeaders)
header = curl_slist_append(header, h.c_str());
curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER,
header);

View File

@ -28,6 +28,8 @@ class RemoteTextThread : public QThread {
std::string contentType;
std::string postData;
std::vector<std::string> extraHeaders;
int timeoutSec = 0;
void run() override;
@ -46,6 +48,19 @@ public:
postData (postData_),
timeoutSec (timeoutSec_)
{}
inline RemoteTextThread(
std::string url_,
std::vector<std::string> &&extraHeaders_,
std::string contentType_ = std::string(),
std::string postData_ = std::string(),
int timeoutSec_ = 0)
: url (url_),
contentType (contentType_),
postData (postData_),
extraHeaders (std::move(extraHeaders_)),
timeoutSec (timeoutSec_)
{}
};
bool GetRemoteFile(