curl_easy_duphandle.3 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_easy_duphandle 3 "19 Sep 2014" "libcurl" "libcurl Manual"
  25. .SH NAME
  26. curl_easy_duphandle - Clone a libcurl session handle
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURL *curl_easy_duphandle(CURL *handle);
  31. .fi
  32. .SH DESCRIPTION
  33. This function will return a new curl handle, a duplicate, using all the
  34. options previously set in the input curl \fIhandle\fP. Both handles can
  35. subsequently be used independently and they must both be freed with
  36. \fIcurl_easy_cleanup(3)\fP.
  37. All strings that the input handle has been told to point to (as opposed to
  38. copy) with previous calls to \fIcurl_easy_setopt(3)\fP using char * inputs,
  39. will be pointed to by the new handle as well. You must therefore make sure to
  40. keep the data around until both handles have been cleaned up.
  41. The new handle will \fBnot\fP inherit any state information, no connections,
  42. no SSL sessions and no cookies. It also will not inherit any share object
  43. states or options (it will be made as if \fICURLOPT_SHARE(3)\fP was set to
  44. NULL).
  45. In multi-threaded programs, this function must be called in a synchronous way,
  46. the input handle may not be in use when cloned.
  47. .SH EXAMPLE
  48. .nf
  49. CURL *curl = curl_easy_init();
  50. CURL *nother;
  51. if(curl) {
  52. CURLcode res;
  53. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  54. nother = curl_easy_duphandle(curl);
  55. res = curl_easy_perform(nother);
  56. curl_easy_cleanup(nother);
  57. curl_easy_cleanup(curl);
  58. }
  59. .fi
  60. .SH AVAILABILITY
  61. Added in 7.9
  62. .SH RETURN VALUE
  63. If this function returns NULL, something went wrong and no valid handle was
  64. returned.
  65. .SH "SEE ALSO"
  66. .BR curl_easy_init "(3)," curl_easy_cleanup "(3)," curl_easy_reset "(3),"
  67. .BR curl_global_init "(3)"