Skip to content
Andrew Lambert edited this page May 21, 2016 · 15 revisions

##Synchronous This example performs a synchronous HTTP TRACE request on the calling thread. TRACE is semantically a download operation, so we use download semantics while overriding the default method (GET) by using cURLClient.SetRequestMethod.

  Dim curl As New cURLClient
  If Not curl.SetRequestMethod("TRACE") Then MsgBox(libcURL.FormatError(curl.LastError))
  If curl.Get("http://www.example.com/") Then ' download semantics
    Dim tracereply As String = curl.GetDownloadedData()
  Else
    MsgBox(libcURL.FormatError(curl.LastError))
  End If

##Asynchronous This example performs an asynchronous HTTP TRACE request in a console application, and prints the output directly to the screen. TRACE is semantically a download operation, so we use download semantics while overriding the default method (GET) by using cURLClient.SetRequestMethod. 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
  If Not curl.SetRequestMethod("TRACE") Then MsgBox(libcURL.FormatError(curl.LastError))
  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