1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_easy_duphandle 5Section: 3 6Source: libcurl 7See-also: 8 - curl_easy_cleanup (3) 9 - curl_easy_init (3) 10 - curl_easy_reset (3) 11 - curl_global_init (3) 12--- 13 14# NAME 15 16curl_easy_duphandle - Clone a libcurl session handle 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURL *curl_easy_duphandle(CURL *handle); 24~~~ 25 26# DESCRIPTION 27 28This function returns a new curl handle, a duplicate, using all the options 29previously set in the input curl *handle*. Both handles can subsequently be 30used independently and they must both be freed with curl_easy_cleanup(3). 31 32Any options that the input handle has been told to point to (as opposed to 33copy) with previous calls to curl_easy_setopt(3), are pointed to by the new 34handle as well. You must therefore make sure to keep the data around until 35both handles have been cleaned up. 36 37The new handle does **not** inherit any state information, no connections, no 38SSL sessions and no cookies. It also does not inherit any share object states 39or options (created as if CURLOPT_SHARE(3) was set to NULL). 40 41If the source handle has HSTS or alt-svc enabled, the duplicate gets data read 42data from the main filename to populate the cache. 43 44In multi-threaded programs, this function must be called in a synchronous way, 45the input handle may not be in use when cloned. 46 47# EXAMPLE 48 49~~~c 50int main(void) 51{ 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 CURLcode res; 55 CURL *nother; 56 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 57 nother = curl_easy_duphandle(curl); 58 res = curl_easy_perform(nother); 59 curl_easy_cleanup(nother); 60 curl_easy_cleanup(curl); 61 } 62} 63~~~ 64 65# AVAILABILITY 66 67Added in 7.9 68 69# RETURN VALUE 70 71If this function returns NULL, something went wrong and no valid handle was 72returned. 73