This commit is contained in:
2025-09-16 18:42:43 -04:00
commit ed50dc81dc
10 changed files with 2346 additions and 0 deletions

24
examples/getinfo.odin Normal file
View File

@@ -0,0 +1,24 @@
package examples
import "core:fmt"
import "core:testing"
import curl "../"
@(test)
getinfo :: proc(t: ^testing.T) {
res: curl.Code
hCurl := curl.easy_init()
if hCurl == nil do testing.fail_now(t, "failed to init curl")
defer curl.easy_cleanup(hCurl);
curl.easy_setopt(hCurl, .URL, "https://www.example.com/")
res = curl.easy_perform(hCurl);
if res != .OK do testing.fail_now(t, fmt.tprintf("got non-OK response for URL: %v", res))
ct: cstring
res = curl.easy_getinfo(hCurl, .CONTENT_TYPE, &ct);
if res != .OK || ct == nil do testing.fail_now(t, "could not read Content-Type")
testing.expectf(t, true, "Content-Type: %s\n", ct)
}