'
' Download a binary file example over HTTP using CURL - PvE december 2010
'

' Include the CURL context
INCLUDE "curl.bac"

CONST filename$ = "documentation.pdf"

' File where we store the download
OPEN filename$ FOR WRITING AS download

' Create the handle
easyhandle = curl_easy_init()

' Set the options
curl_easy_setopt(easyhandle, CURLOPT_URL, CONCAT$("http://www.basic-converter.org/", filename$))
curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, download)

' Perform the GET
success = curl_easy_perform(easyhandle)

' Cleanup
curl_easy_cleanup(easyhandle)

' Close filehandle
CLOSE FILE download

' Print Curl version
PRINT NL$, "Downloaded '", filename$, "' using CURL version: ", curl_version$(), NL$