This repository has been archived on 2025-09-16. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
libcurl-odin/examples/getinfo.odin
2025-09-16 18:42:43 -04:00

25 lines
646 B
Odin

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)
}