curl_easy_duphandle.3 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. .\" generated by cd2nroff 0.1 from curl_easy_duphandle.md
  2. .TH curl_easy_duphandle 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_easy_duphandle \- clone an easy handle
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURL *curl_easy_duphandle(CURL *handle);
  9. .fi
  10. .SH DESCRIPTION
  11. This function returns a new curl handle, a duplicate, using all the options
  12. previously set in the input curl \fIhandle\fP. Both handles can subsequently be
  13. used independently and they must both be freed with \fIcurl_easy_cleanup(3)\fP.
  14. Any options that the input handle has been told to point to (as opposed to
  15. copy) with previous calls to \fIcurl_easy_setopt(3)\fP, are pointed to by the new
  16. handle as well. You must therefore make sure to keep the data around until
  17. both handles have been cleaned up.
  18. The new handle does \fBnot\fP inherit any state information, no connections, no
  19. SSL sessions and no cookies. It also does not inherit any share object states
  20. or options (created as if \fICURLOPT_SHARE(3)\fP was set to NULL).
  21. If the source handle has HSTS or alt\-svc enabled, the duplicate gets data read
  22. data from the main filename to populate the cache.
  23. In multi\-threaded programs, this function must be called in a synchronous way,
  24. the input handle may not be in use when cloned.
  25. .SH PROTOCOLS
  26. This functionality affects all supported protocols
  27. .SH EXAMPLE
  28. .nf
  29. int main(void)
  30. {
  31. CURL *curl = curl_easy_init();
  32. if(curl) {
  33. CURLcode res;
  34. CURL *nother;
  35. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  36. nother = curl_easy_duphandle(curl);
  37. res = curl_easy_perform(nother);
  38. curl_easy_cleanup(nother);
  39. curl_easy_cleanup(curl);
  40. }
  41. }
  42. .fi
  43. .SH AVAILABILITY
  44. Added in curl 7.9
  45. .SH RETURN VALUE
  46. If this function returns NULL, something went wrong and no valid handle was
  47. returned.
  48. .SH SEE ALSO
  49. .BR curl_easy_cleanup (3),
  50. .BR curl_easy_init (3),
  51. .BR curl_easy_reset (3),
  52. .BR curl_global_init (3)