1CURLSHOPT_SHARE(3) libcurl CURLSHOPT_SHARE(3)
2
3
4
6 CURLSHOPT_SHARE - add data to share
7
9 #include <curl/curl.h>
10
11 CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_SHARE, long type);
12
14 The type parameter specifies what specific data that should be shared
15 and kept in the share object that was created with curl_share_init(3).
16 The given type must be be one of the values described below. You can
17 set CURLSHOPT_SHARE(3) multiple times with different data arguments to
18 have the share object share multiple types of data. Unset a type again
19 by setting CURLSHOPT_UNSHARE(3).
20
21 CURL_LOCK_DATA_COOKIE
22 Cookie data will be shared across the easy handles using this
23 shared object. Note that this does not activate an easy han‐
24 dle's cookie handling. You can do that separately by using CUR‐
25 LOPT_COOKIEFILE(3) for example.
26
27 CURL_LOCK_DATA_DNS
28 Cached DNS hosts will be shared across the easy handles using
29 this shared object. Note that when you use the multi interface,
30 all easy handles added to the same multi handle will share DNS
31 cache by default without using this option.
32
33 CURL_LOCK_DATA_SSL_SESSION
34 SSL session IDs will be shared across the easy handles using
35 this shared object. This will reduce the time spent in the SSL
36 handshake when reconnecting to the same server. Note SSL session
37 IDs are reused within the same easy handle by default. Note this
38 symbol was added in 7.10.3 but was not implemented until 7.23.0.
39
40 CURL_LOCK_DATA_CONNECT
41 Put the connection cache in the share object and make all easy
42 handles using this share object share the connection cache.
43
44 It is not supported to share connections between multiple con‐
45 current threads.
46
47 Connections that are used for HTTP/1.1 Pipelining or HTTP/2 mul‐
48 tiplexing only get additional transfers added to them if the ex‐
49 isting connection is held by the same multi or easy handle.
50 libcurl does not support doing HTTP/2 streams in different
51 threads using a shared connection.
52
53 Support for CURL_LOCK_DATA_CONNECT was added in 7.57.0, but the
54 symbol existed before this.
55
56 Note that when you use the multi interface, all easy handles
57 added to the same multi handle will share connection cache by
58 default without using this option.
59
60 CURL_LOCK_DATA_PSL
61 The Public Suffix List stored in the share object is made avail‐
62 able to all easy handle bound to the later. Since the Public
63 Suffix List is periodically refreshed, this avoids updates in
64 too many different contexts.
65
66 Added in 7.61.0.
67
68 Note that when you use the multi interface, all easy handles
69 added to the same multi handle will share PSL cache by default
70 without using this option.
71
72 CURL_LOCK_DATA_HSTS
73 The in-memory HSTS cache.
74
75 It is not supported to share the HSTS between multiple concur‐
76 rent threads.
77
78 Added in 7.88.0
79
81 All
82
84 CURLSHcode sh;
85 share = curl_share_init();
86 sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
87 if(sh)
88 printf("Error: %s\n", curl_share_strerror(sh));
89
91 Added in 7.10
92
94 CURLSHE_OK (zero) means that the option was set properly, non-zero
95 means an error occurred. See libcurl-errors(3) for the full list with
96 descriptions.
97
99 CURLSHOPT_UNSHARE(3), curl_share_setopt(3), curl_share_cleanup(3),
100 curl_share_init(3)
101
102
103
104ibcurl 8.2.1 April 26, 2023 CURLSHOPT_SHARE(3)