Skip to content

libcURL.ShareHandle

Andrew Lambert edited this page Jan 14, 2023 · 30 revisions

libcURL.ShareHandle

Class Declaration

 Protected Class ShareHandle
 Inherits libcURL.cURLHandle

Remarks

This class wraps the curl_share API.

EasyHandles that are added to a ShareHandle instance may share SSL session data, DNS caches, connection pools, and/or HTTP cookies. By default nothing is shared. You must enable the share options you want before adding any EasyHandles to the share. Doing so after will raise an error (CURLSHE_IN_USE (2))

Methods

Properties

Example

This example creates two instances of EasyHandle and then adds both of them to a ShareHandle that is configured to share cookies only:

  Dim share As New libcURL.ShareHandle
  Dim easy1 As New libcURL.EasyHandle
  Dim easy2 As New libcURL.EasyHandle
  easy1.CookieEngine.Enabled = True
  easy2.CookieEngine.Enabled = True
  
  share.ShareCookies = True ' must enable the share type before adding EasyHandles
  share.AddTransfer(easy1)
  share.AddTransfer(easy2)
  
  easy1.URL = "www.example.com/file.html"
  easy2.URL = "www.example.com/image.png"
  
  Dim mb1 As New MemoryBlock(0)
  Dim b1 As New BinaryStream(mb1)
  easy1.DownloadStream = b1

  Dim mb2 As New MemoryBlock(0)
  Dim b2 As New BinaryStream(mb2)
  easy2.DownloadStream = b2
  
  Call easy1.Perform()
  Call easy2.Perform()
  b1.Close
  b2.Close
  
  share.RemoveTransfer(easy1)
  share.RemoveTransfer(easy2)

See also

Clone this wiki locally