(bind-func curl_perform_request
(lambda (handle cdat:curl_dat*)
(let ((status (curl_easy_perform handle)))
(if (<> status 0)
(begin (printf "Error accessing URL: %s\n" (curl_easy_strerror status))
(tset! cdat 0 null)
(tset! cdat 1 0)
cdat)
(begin
(curl_easy_cleanup handle)
;; null-terminate the dat buffer
(let ((ptr (tref cdat 0)))
(pset! ptr (tref cdat 1) 0))
cdat)))))