diff options
Diffstat (limited to 'internal/curl/curl.ha')
| -rw-r--r-- | internal/curl/curl.ha | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/curl/curl.ha b/internal/curl/curl.ha index 3eeb4c6..43fbc52 100644 --- a/internal/curl/curl.ha +++ b/internal/curl/curl.ha @@ -71,3 +71,24 @@ export fn get(url: const str, resp: *response) (void | curlerror) = { }; resp.status = rc; }; + +// Makes a HTTP request to the given url and fills resp with the body, HTTP +// status and body size. +export fn getmulti(url: const str, resp: *response) (void | curlerror) = { + let cm = ccurl::curl_multi_init(); + defer ccurl::curl_multi_cleanup(cm); + let c = ccurl::curl_easy_init(); + defer ccurl::curl_easy_cleanup(c); + + let c_url = c::fromstr(url); + defer free(c_url); + let res = ccurl::curl_easy_setopt(c, ccurl::CURLOPT_URL, c_url); + if (res != 0) { + return res: setopterr; + }; + ccurl::curl_multi_add_handle(cm, c); + defer ccurl::curl_multi_remove_handle(cm, c); + + let still_running = 0; + ccurl::curl_multi_perform(cm, &still_running); +}; |
