diff options
| author | Julian Hurst <ark@mansus.space> | 2024-03-18 00:25:38 +0100 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2024-03-18 00:25:43 +0100 |
| commit | 2629cc8ef2d52e3dc1ca1556ec5d0a97f3469bb5 (patch) | |
| tree | 2ed3b4f92dfff3963cb0924059d691b748aa2263 /internal/curl/curl.ha | |
| parent | a5fd529e47ecbd4de465b46d943b34f88a500467 (diff) | |
| download | hacurl-multi.tar.gz | |
Multi shitmulti
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); +}; |
