New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
static auto curl_deleter = [] (CURL *curl) {curl_easy_cleanup(curl);};
|
||||
static auto curl_deleter = [](CURL *curl) { curl_easy_cleanup(curl); };
|
||||
using Curl = unique_ptr<CURL, decltype(curl_deleter)>;
|
||||
|
||||
static size_t string_write(char *ptr, size_t size, size_t nmemb, string &str)
|
||||
|
|
@ -53,12 +53,11 @@ void RemoteTextThread::run()
|
|||
struct curl_slist *header = nullptr;
|
||||
string str;
|
||||
|
||||
header = curl_slist_append(header,
|
||||
versionString.c_str());
|
||||
header = curl_slist_append(header, versionString.c_str());
|
||||
|
||||
if (!contentTypeString.empty()) {
|
||||
header = curl_slist_append(header,
|
||||
contentTypeString.c_str());
|
||||
contentTypeString.c_str());
|
||||
}
|
||||
|
||||
for (std::string &h : extraHeaders)
|
||||
|
|
@ -66,18 +65,15 @@ void RemoteTextThread::run()
|
|||
|
||||
curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl.get(), CURLOPT_ACCEPT_ENCODING, "");
|
||||
curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER,
|
||||
header);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_ERRORBUFFER,
|
||||
error);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER, header);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_ERRORBUFFER, error);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION,
|
||||
string_write);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA,
|
||||
&str);
|
||||
string_write);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &str);
|
||||
|
||||
if (timeoutSec)
|
||||
curl_easy_setopt(curl.get(), CURLOPT_TIMEOUT,
|
||||
timeoutSec);
|
||||
timeoutSec);
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x072400
|
||||
// A lot of servers don't yet support ALPN
|
||||
|
|
@ -86,7 +82,7 @@ void RemoteTextThread::run()
|
|||
|
||||
if (!postData.empty()) {
|
||||
curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDS,
|
||||
postData.c_str());
|
||||
postData.c_str());
|
||||
}
|
||||
|
||||
code = curl_easy_perform(curl.get());
|
||||
|
|
@ -101,7 +97,7 @@ void RemoteTextThread::run()
|
|||
}
|
||||
|
||||
static size_t header_write(char *ptr, size_t size, size_t nmemb,
|
||||
vector<string> &list)
|
||||
vector<string> &list)
|
||||
{
|
||||
string str;
|
||||
|
||||
|
|
@ -118,16 +114,10 @@ static size_t header_write(char *ptr, size_t size, size_t nmemb,
|
|||
return total;
|
||||
}
|
||||
|
||||
bool GetRemoteFile(
|
||||
const char *url,
|
||||
std::string &str,
|
||||
std::string &error,
|
||||
long *responseCode,
|
||||
const char *contentType,
|
||||
const char *postData,
|
||||
std::vector<std::string> extraHeaders,
|
||||
std::string *signature,
|
||||
int timeoutSec)
|
||||
bool GetRemoteFile(const char *url, std::string &str, std::string &error,
|
||||
long *responseCode, const char *contentType,
|
||||
const char *postData, std::vector<std::string> extraHeaders,
|
||||
std::string *signature, int timeoutSec)
|
||||
{
|
||||
vector<string> header_in_list;
|
||||
char error_in[CURL_ERROR_SIZE];
|
||||
|
|
@ -148,12 +138,11 @@ bool GetRemoteFile(
|
|||
if (curl) {
|
||||
struct curl_slist *header = nullptr;
|
||||
|
||||
header = curl_slist_append(header,
|
||||
versionString.c_str());
|
||||
header = curl_slist_append(header, versionString.c_str());
|
||||
|
||||
if (!contentTypeString.empty()) {
|
||||
header = curl_slist_append(header,
|
||||
contentTypeString.c_str());
|
||||
contentTypeString.c_str());
|
||||
}
|
||||
|
||||
for (std::string &h : extraHeaders)
|
||||
|
|
@ -161,24 +150,21 @@ bool GetRemoteFile(
|
|||
|
||||
curl_easy_setopt(curl.get(), CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_ACCEPT_ENCODING, "");
|
||||
curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER,
|
||||
header);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_ERRORBUFFER,
|
||||
error_in);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER, header);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_ERRORBUFFER, error_in);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION,
|
||||
string_write);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA,
|
||||
&str);
|
||||
string_write);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &str);
|
||||
if (signature) {
|
||||
curl_easy_setopt(curl.get(), CURLOPT_HEADERFUNCTION,
|
||||
header_write);
|
||||
header_write);
|
||||
curl_easy_setopt(curl.get(), CURLOPT_HEADERDATA,
|
||||
&header_in_list);
|
||||
&header_in_list);
|
||||
}
|
||||
|
||||
if (timeoutSec)
|
||||
curl_easy_setopt(curl.get(), CURLOPT_TIMEOUT,
|
||||
timeoutSec);
|
||||
timeoutSec);
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x072400
|
||||
// A lot of servers don't yet support ALPN
|
||||
|
|
@ -187,13 +173,13 @@ bool GetRemoteFile(
|
|||
|
||||
if (postData) {
|
||||
curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDS,
|
||||
postData);
|
||||
postData);
|
||||
}
|
||||
|
||||
code = curl_easy_perform(curl.get());
|
||||
if (responseCode)
|
||||
curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE,
|
||||
responseCode);
|
||||
responseCode);
|
||||
|
||||
if (code != CURLE_OK) {
|
||||
error = error_in;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue