| 72 | } |
| 73 | |
| 74 | CURL* RequestObject::construct() { |
| 75 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); |
| 76 | curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, timeout_s); |
| 77 | curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, timeout_s); |
| 78 | curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1); |
| 79 | util::set_curl_proxy(curl, proxy); |
| 80 | util::set_curl_ssl_cert(curl); |
| 81 | if (method == Method::POST) { |
| 82 | if (mime) { |
| 83 | curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime); |
| 84 | } else if (post_data) { |
| 85 | curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_data->c_str()); |
| 86 | } |
| 87 | } else if (method == Method::DEL) { |
| 88 | curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); |
| 89 | } |
| 90 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); |
| 91 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &callback_lambda); |
| 92 | curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); |
| 93 | curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); |
| 94 | curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback); |
| 95 | curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &progress); |
| 96 | if (headers_c) { |
| 97 | curl_slist_free_all(headers_c); |
| 98 | } |
| 99 | for (const auto& header : headers) { |
| 100 | headers_c = curl_slist_append(headers_c, header.c_str()); |
| 101 | } |
| 102 | curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers_c); |
| 103 | constructed = true; |
| 104 | return curl; |
| 105 | } |
| 106 | |
| 107 | void RequestObject::perform() { |
| 108 | if (!constructed) { |
no test coverage detected