Skip to content

HTTP persistent connection example

Andrew Lambert edited this page Jan 8, 2023 · 7 revisions

Connection reuse is on by default and will be used if the server and protocol both support it. Use the same EasyHandle when making multiple requests of the same server to take advantage of this feature.

This example retrieves a web page and an image from the same website. If the server supports it then both transfers will use the same connection.

  Dim c As New cURLClient
  Dim page As String
  Dim logo As Picture

  If c.Get("http://www.example.com/index.html") Then ' Transfer #1
    page = c.GetDownloadedData
  End If

  If c.Get("http://www.example.com/logo.png") Then  ' Transfer #2
    logo = Picture.FromData(c.GetDownloadedData)
  End If

To disable connection reuse, set EasyHandle.AutoDisconnect to True.

Refer to the MultiHandle class for HTTP pipelining and multiplexing.

Clone this wiki locally