CURLOPT_URL
pub val CURLOPT_URL = 10002extern (C) fn curl_easy_init() ref void = trust { ... } = "curl_easy_init"extern (C) fn curl_easy_cleanup(handle: ref void) void = trust { ... } = "curl_easy_cleanup"extern (C) fn curl_easy_setopt(handle: ref void, opt: i32, ...) i64 = trust { ... } = "curl_easy_setopt"extern (C) fn curl_easy_perform(handle: ref void) i64 = trust { ... } = "curl_easy_perform"extern (C) fn curl_easy_getinfo(handle: ref void, info: i32, ...) i64 = trust { ... } = "curl_easy_getinfo"extern (C) fn curl_slist_append(list: ref void, str: ref u8) ref void = trust { ... } = "curl_slist_append"extern (C) fn curl_slist_free_all(list: ref void) void = trust { ... } = "curl_slist_free_all"extern (C) fn curl_global_init(flags: i64) i64 = trust { ... } = "curl_global_init"extern (C) fn curl_global_cleanup() void = trust { ... } = "curl_global_cleanup"extern (C) fn socket(domain: i32, type_: i32, protocol: i32) i32 = trust { ... } = "socket"extern (C) fn bind(fd: i32, addr: ref void, addrlen: i32) i32 = trust { ... } = "bind"extern (C) fn listen(fd: i32, backlog: i32) i32 = trust { ... } = "listen"extern (C) fn accept(fd: i32, addr: ref void, addrlen: ref void) i32 = trust { ... } = "accept"extern (C) fn send(fd: i32, buf: ref void, len: i64, flags: i32) i64 = trust { ... } = "send"extern (C) fn recv(fd: i32, buf: ref void, len: i64, flags: i32) i64 = trust { ... } = "recv"extern (C) fn close(fd: i32) i32 = trust { ... } = "close"extern (C) fn htons(port: i32) i32 = trust { ... } = "htons"extern (C) fn setsockopt(fd: i32, level: i32, opt: i32, vl: ref void, len: i32) i32 = trust { ... } = "setsockopt"extern (C) fn memset(ptr: ref void, vl: i32, len: i64) ref void = trust { ... } = "memset"extern (C) fn memcpy(dst: ref void, src: ref void, len: i64) ref void = trust { ... } = "memcpy"pub val CURLOPT_URL = 10002pub val CURLOPT_WRITEFUNCTION = 20011pub val CURLOPT_WRITEDATA = 10001pub val CURLOPT_HTTPHEADER = 10023pub val CURLOPT_POSTFIELDS = 10015pub val CURLOPT_CUSTOMREQUEST = 10036pub val CURLINFO_RESPONSE_CODE = 2097154pub val CURL_GLOBAL_DEFAULT = 3pub val AF_INET = 2pub val IPPROTO_TCP = 6type Buffer = { data: mut ref void, len: mut i64, cap: mut i64, failed: mut bool }| Name | Type |
|---|---|
data | mut ref void |
len | mut i64 |
cap | mut i64 |
failed | mut bool |
type Response = { body: mut ref u8, status: mut i64, len: mut i64 }An owned HTTP response.
| Name | Type |
|---|---|
body | mut ref u8 |
status | mut i64 |
len | mut i64 |
type I32Slot = { value: mut i32 }| Name | Type |
|---|---|
value | mut i32 |
type I64Slot = { value: mut i64 }| Name | Type |
|---|---|
value | mut i64 |
pub fn curl_write_cb(ptr: ref void, size: i64, nmemb: i64, userdata: ref void) i64 = trust { ... }Internal write callback for curl. Signature matches: size_t write_fn(u8 *ptr, size_t size, size_t nmemb, void *userdata)
fn buf_new() ref Buffer = trust { ... }fn do_request[A: allocators.GeneralAllocator](ac: A, handle: ref void) ref ResponsePerform a curl request, capturing the response body via the write callback. Returns a Response allocated with the provided allocator.
type Http = { }type ServerHandle = { port: mut i64, fd: mut i32 }| Name | Type |
|---|---|
port | mut i64 |
fd | mut i32 |
pub fn (Http) init() voidInitialise the curl global state. Call once at program start.
pub fn (Http) cleanup() void = trust { ... }Clean up the curl global state. Call once at program end.
pub fn (Http) get[A: allocators.GeneralAllocator](ac: A, url: ref u8) ref ResponsePerform an HTTP GET request. Returns a Response allocated with the provided allocator; caller must call Http.free_response().
pub fn (Http) post_request[A: allocators.GeneralAllocator](ac: A, url: ref u8, body: ref u8, content_type: ref u8) ref ResponsePerform an HTTP POST request with a body string. Returns a Response allocated with the provided allocator; caller must call Http.free_response().
pub fn (Http) request[A: allocators.GeneralAllocator](ac: A, method: ref u8, url: ref u8, body: ref u8, headers: ref void) ref ResponsePerform an arbitrary HTTP request (GET, POST, PUT, DELETE, PATCH …).
pub fn (Http) free_response[A: allocators.GeneralAllocator](ac: A, resp: ref Response) voidFree a Response returned by Http.get / Http.post / Http.request with the same allocator used to create it.
pub fn (Http) status(resp: ref Response) i64Read the HTTP status code from a Response.
pub fn (Http) body(resp: ref Response) ref u8Read the body pointer from a Response.
pub fn (Http) body_len(resp: ref Response) i64Read the body length from a Response.
pub fn (Http) make_headers(header: ref u8) ref void = trust { ... }Build a curl slist header list from a single "Key: Value" string.
pub fn (Http) append_header(list: ref void, header: ref u8) ref void = trust { ... }Append a header to an existing slist.
pub fn (Http) free_headers(list: ref void) void = trust { ... }Free a header list created with Http.make_headers / Http.append_header.
type TcpServer = { }pub fn (TcpServer) listen[A: allocators.GeneralAllocator](ac: A, port: i32) ref ServerHandleCreate a TCP server bound to `port` and start listening. Returns a server handle allocated with the provided allocator; caller must call TcpServer.close().
pub fn (TcpServer) accept(server: ref ServerHandle) i32 = trust { ... }Accept the next incoming connection. Returns the client socket fd, or -1 on error.
pub fn (TcpServer) send(client_fd: i32, data: ref u8, len: i64) i64 = trust { ... }Send bytes over a client socket fd. Returns the number of bytes sent, or -1 on error.
pub fn (TcpServer) recv(client_fd: i32, buf: ref u8, max_len: i64) i64 = trust { ... }Receive bytes from a client socket fd into buf (at most max_len bytes). Returns the number of bytes received, or -1 on error / 0 on close.
pub fn (TcpServer) close_client(client_fd: i32) void = trust { ... }Close a client socket fd.
pub fn (TcpServer) close[A: allocators.GeneralAllocator](ac: A, server: ref ServerHandle) voidShut down and free the server handle.
pub fn (TcpServer) port(server: ref ServerHandle) i64Read the listening port from a server handle.
pub fn (TcpServer) fd(server: ref ServerHandle) i32Read the listening fd from a server handle.