CURLOPT_SHARE.3 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2017, 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.haxx.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. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_SHARE 3 "May 31, 2017" "libcurl 7.61.1" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_SHARE \- specify share handle to use
  26. .SH SYNOPSIS
  27. #include <curl/curl.h>
  28. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SHARE, CURLSH *share);
  29. .SH DESCRIPTION
  30. Pass a \fIshare\fP handle as a parameter. The share handle must have been
  31. created by a previous call to \fIcurl_share_init(3)\fP. Setting this option,
  32. will make this curl handle use the data from the shared handle instead of
  33. keeping the data to itself. This enables several curl handles to share
  34. data. If the curl handles are used simultaneously in multiple threads, you
  35. \fBMUST\fP use the locking methods in the share handle. See
  36. \fIcurl_share_setopt(3)\fP for details.
  37. If you add a share that is set to share cookies, your easy handle will use
  38. that cookie cache and get the cookie engine enabled. If you unshare an object
  39. that was using cookies (or change to another object that doesn't share
  40. cookies), the easy handle will get its cookie engine disabled.
  41. Data that the share object is not set to share will be dealt with the usual
  42. way, as if no share was used.
  43. Set this option to NULL again to stop using that share object.
  44. .SH DEFAULT
  45. NULL
  46. .SH PROTOCOLS
  47. All
  48. .SH EXAMPLE
  49. .nf
  50. CURL *curl = curl_easy_init();
  51. CURL *curl2 = curl_easy_init(); /* a second handle */
  52. if(curl) {
  53. CURLSH *shobject = curl_share_init();
  54. curl_share_setopt(shobject, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  55. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  56. curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
  57. curl_easy_setopt(curl, CURLOPT_SHARE, shobject);
  58. ret = curl_easy_perform(curl);
  59. curl_easy_cleanup(curl);
  60. /* the second handle shares cookies from the first */
  61. curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/second");
  62. curl_easy_setopt(curl2, CURLOPT_COOKIEFILE, "");
  63. curl_easy_setopt(curl2, CURLOPT_SHARE, shobject);
  64. ret = curl_easy_perform(curl2);
  65. curl_easy_cleanup(curl2);
  66. curl_share_cleanup(shobject);
  67. }
  68. .fi
  69. .SH AVAILABILITY
  70. Always
  71. .SH RETURN VALUE
  72. Returns CURLE_OK
  73. .SH "SEE ALSO"
  74. .BR CURLOPT_COOKIE "(3), "