Repository navigation
Share Interface
The Share interface allows multiple easy handles to share state — cookies, DNS cache, or SSL session data — through a common share_handle.
share_handle := curl.ShareInit()ShareSetOpt configures what is shared. The option name and value follow libcurl's CURLSHOPT_* definitions:
curl.ShareSetOpt("SHARE", "COOKIE", share_handle)For the full list of shareable data types and options, see the libcurl share interface reference.
AddEasyToShare links an easy handle to the share handle. RemoveEasyFromShare disassociates it:
curl.AddEasyToShare(easyA, share_handle)
curl.AddEasyToShare(easyB, share_handle)The most common use case is sharing cookies across multiple requests:
easyA := curl.EasyInit()
easyB := curl.EasyInit()
share_handle := curl.ShareInit()
curl.ShareSetOpt("SHARE", "COOKIE", share_handle)
curl.AddEasyToShare(easyA, share_handle)
curl.AddEasyToShare(easyB, share_handle)
; Set a cookie via easyA
; COOKIEFILE must be set AFTER ShareSetOpt
curl.SetOpt("COOKIEFILE", "", easyA)
curl.SetOpt("URL", "https://httpbin.org/cookies/set?tidbit=is%20a%20cookie", easyA)
curl.Sync(easyA)
; Read the cookie via easyB — it sees what easyA set
curl.SetOpt("COOKIEFILE", "", easyB)
curl.SetOpt("URL", "https://httpbin.org/cookies", easyB)
curl.Sync(easyB)
body := curl.GetLastBody(, easyB)
; body contains the cookie set by easyAOrdering note:
COOKIEFILEmust be set on the easy handle afterShareSetOpthas configured the share handle. Setting it before will not participate in the shared cookie store.
ShareCleanup releases the share handle. Easy handles remain usable but lose their shared state:
curl.ShareCleanup(share_handle)- SSL Sessions — SSL session resumption via export/import
- Share Handle Reference — full method list
Foundations
Operations
- Download Modes
- Setting and Listing Options
- Setting and Inspecting Headers
- POST and Upload
- Multiple Easy Handles
- Async and Multi Interface
- URL Construction
- Share Interface
- MIME and Multipart
- Raw Send and Receive
- Pause and Resume
- WebSocket
- SSL Sessions
- Debug and Diagnostics
API Reference
- Easy Handle Reference
- Multi Handle Reference
- Share Handle Reference
- MIME Handle Reference
- URL Handle Reference
- Utility Methods Reference
- WebSocket Reference
Code Snippets