Skip to content
Andrew Lambert edited this page May 27, 2015 · 25 revisions

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
  If curl.GetStatusCode = 200 Then
    Dim page As String = curl.GetDownloadedData()
  Else
    MsgBox("HTTP Status: " + Str(curl.GetStatusCode))
  End If
Else
  MsgBox(libcURL.FormatError(curl.LastError))
End If

This example performs an asynchronous HTTP GET in a console application, and prints the output directly to the screen:

  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

  Dim status As Integer = curl.GetStatusCode
  If status <> 200 Then 
    Print("Got status: " + Str(status))
  End If
Clone this wiki locally