MCPcopy Create free account
hub / github.com/audacity/audacity / perform

Method perform

libraries/lib-network-manager/curl/CurlResponse.cpp:243–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243void CurlResponse::perform ()
244{
245 CurlHandleManager::Handle handle = mHandleManager->getHandle (mVerb, mRequest.getURL ());
246
247 handle.setOption (CURLOPT_WRITEFUNCTION, WriteCallback);
248 handle.setOption (CURLOPT_WRITEDATA, this);
249
250 handle.setOption (CURLOPT_HEADERFUNCTION, HeaderCallback);
251 handle.setOption (CURLOPT_HEADERDATA, this);
252
253 handle.setOption (CURLOPT_XFERINFOFUNCTION, CurlProgressCallback);
254 handle.setOption (CURLOPT_XFERINFODATA, this);
255
256 handle.setOption (CURLOPT_FOLLOWLOCATION, mRequest.getMaxRedirects () == 0 ? 0 : 1);
257 handle.setOption (CURLOPT_MAXREDIRS, mRequest.getMaxRedirects ());
258
259 handle.setOption (CURLOPT_NOPROGRESS, 0L);
260
261 handle.setOption (CURLOPT_CONNECTTIMEOUT_MS,
262 std::chrono::duration_cast<std::chrono::milliseconds> (mRequest.getTimeout()).count ()
263 );
264
265 handle.appendCookies (mRequest.getCookies ());
266
267 curl_mime* mimeList = nullptr;
268
269 if (mForm != nullptr)
270 {
271 mimeList = curl_mime_init(handle.getCurlHandle());
272
273 for (size_t i = 0; i < mForm->GetPartsCount(); ++i)
274 {
275 auto part = mForm->GetPart(i);
276
277 curl_mimepart* curlPart = curl_mime_addpart(mimeList);
278
279 const auto& headers = part->GetHeaders();
280
281 if (headers.getHeadersCount() > 0)
282 {
283 curl_slist* partHeaders = nullptr;
284
285 for (auto header : headers)
286 {
287 partHeaders = curl_slist_append(
288 partHeaders, (header.Name + ": " + header.Value).c_str());
289 }
290
291 curl_mime_headers(curlPart, partHeaders, 1);
292 }
293
294 curl_mime_data_cb(
295 curlPart, part->GetSize(), curl_read_callback(MimePartRead),
296 curl_seek_callback(MimePartSeek), nullptr, part);
297 }
298
299 curl_easy_setopt(handle.getCurlHandle(), CURLOPT_MIMEPOST, mimeList);
300 }

Callers 1

performRequestMethod · 0.45

Calls 15

to_stringFunction · 0.85
finallyFunction · 0.85
getHandleMethod · 0.80
getMaxRedirectsMethod · 0.80
getTimeoutMethod · 0.80
appendCookiesMethod · 0.80
getCurlHandleMethod · 0.80
GetPartsCountMethod · 0.80
GetPartMethod · 0.80
getHeadersCountMethod · 0.80
appendHeaderMethod · 0.80
appendHeadersMethod · 0.80

Tested by

no test coverage detected