MCPcopy Create free account
hub / github.com/LagPixelLOL/ChatGPTCLIBot / construct

Method construct

main/interface/network/RequestObject.cpp:74–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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) {

Callers 1

multi_performFunction · 0.80

Calls 2

set_curl_proxyFunction · 0.85
set_curl_ssl_certFunction · 0.85

Tested by

no test coverage detected