Skip to content
Andrew Lambert edited this page Jun 18, 2021 · 25 revisions

Remarks

HTTP/1.1 GET semantics are the default for all requests made through libcURL. Consequently, HTTP/1.1 GET requests are the simplest kinds of transfer that can be done using libcURL.

Examples

Synchronous

This example performs a synchronous HTTP GET request on the calling thread.

  Dim curl As New cURLClient
  If curl.Get("http://www.example.com/") Then
    Dim page As String = curl.GetDownloadedData()
  Else
    MsgBox(libcURL.FormatError(curl.LastError))
  End If

Asynchronous

This example performs an asynchronous HTTP GET in a console application, and prints the output directly to stdout. The Get method accepts an optional Writeable object to which downloaded data should be written. Because this is a console application an event loop must be supplied for the asynchronous transfers to run on:

  Dim curl As New cURLClient
  curl.Get("http://www.example.com/", stdout) ' stdout implements Writeable
  Do
    App.DoEvents() ' async transfers require an event loop!
  Loop Until curl.IsTransferComplete

  If curl.GetStatusCode <> 200 Then 
    Print("HTTP Status: " + Str(curl.GetStatusCode))
  End If
Clone this wiki locally