337{
338 ::curl_easy_setopt(
curl, CURLOPT_FOLLOWLOCATION, 1L);
339 ::curl_easy_setopt(
curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
340 ::curl_easy_setopt(
curl, CURLOPT_WRITEFUNCTION,
writecb);
341 ::curl_easy_setopt(
curl, CURLOPT_WRITEDATA,
static_cast<void*
>(
this));
343
344 ::curl_easy_setopt(
curl, CURLOPT_NOPROGRESS, 0
L);
345#if LIBCURL_VERSION_MAJOR >= 7 && LIBCURL_VERSION_MINOR >= 32
346 ::curl_easy_setopt(
curl, CURLOPT_XFERINFOFUNCTION,
xfercb);
347 ::curl_easy_setopt(
curl, CURLOPT_XFERINFODATA,
static_cast<void*
>(
this));
348#ifndef _WIN32
350#endif
351#else
352 ::curl_easy_setopt(
curl, CURLOPT_PROGRESSFUNCTION,
xfercb);
353 ::curl_easy_setopt(
curl, CURLOPT_PROGRESSDATA,
static_cast<void*
>(
this));
354#endif
355
357
360 }
361
362 if (
form !=
nullptr) {
363 ::curl_easy_setopt(
curl, CURLOPT_HTTPPOST,
form);
364 }
365
368 ::curl_easy_setopt(
curl, CURLOPT_POSTFIELDSIZE_LARGE,
postfields.size());
369 }
370
371 CURLcode res = ::curl_easy_perform(
curl);
372
374
375 if (res != CURLE_OK) {
376 if (res == CURLE_ABORTED_BY_CALLBACK) {
378
379 Progress dummyprogress(0, 0, 0, 0, std::string());
382 } else {
383
385 }
386 }
387 else if (res == CURLE_WRITE_ERROR) {
389 } else {
391 };
392 } else {
393 long http_status = 0;
394 ::curl_easy_getinfo(
curl, CURLINFO_RESPONSE_CODE, &http_status);
395
396 if (http_status >= 400) {
398 } else {
401 char* ct;
402 res = curl_easy_getinfo(
curl, CURLINFO_PRIMARY_IP, &ct);
403 if ((CURLE_OK == res) && ct) {
405 }
406 }
407 }
408 }
409}
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
unsigned get_logging_level()
Definition utils.cpp:107
#define L(s)
Definition I18N.hpp:18
Http::CompleteFn completefn
Definition Http.cpp:127
std::string curl_error(CURLcode curlcode)
Definition Http.cpp:322
Http::ProgressFn progressfn
Definition Http.cpp:129
static size_t form_file_read_cb(char *buffer, size_t size, size_t nitems, void *userp)
Definition Http.cpp:243
std::string postfields
Definition Http.cpp:120
static size_t writecb(void *data, size_t size, size_t nmemb, void *userp)
Definition Http.cpp:207
static int xfercb(void *userp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
Definition Http.cpp:223
Http::ErrorFn errorfn
Definition Http.cpp:128
static int xfercb_legacy(void *userp, double dltotal, double dlnow, double ultotal, double ulnow)
Definition Http.cpp:238
Http::IPResolveFn ipresolvefn
Definition Http.cpp:130
std::unique_ptr< fs::ifstream > putFile
Definition Http.cpp:124
std::string body_size_error()
Definition Http.cpp:331