11#+TITLE: zig-curl
22#+DATE: 2023-09-16T23:16:15+0800
3- #+LASTMOD: 2025-10-02T10:13:24 +0800
3+ #+LASTMOD: 2025-10-03T12:30:00 +0800
44#+OPTIONS: toc:nil num:nil
55#+STARTUP: content
66
77[[https://img.shields.io/badge/zig%20version-0.15.1-blue.svg]]
8- [[https://img.shields.io/badge/zig%20version-master-blue.svg]]
98[[https://github.com/jiacai2050/zig-curl/actions/workflows/CI.yml][https://github.com/jiacai2050/zig-curl/actions/workflows/CI.yml/badge.svg]]
109[[https://ci.codeberg.org/repos/13257][https://ci.codeberg.org/api/badges/13257/status.svg]]
1110
1211Zig bindings for [[https://curl.haxx.se/libcurl/][libcurl]], a free and easy-to-use client-side URL transfer library.
1312
13+ [[file:docs/logo.svg]]
14+
1415The vendored libraries consist of:
1516| Library | Version |
1617|---------+---------|
@@ -26,11 +27,7 @@ cat examples/basic.zig
2627#+RESULTS:
2728#+begin_src zig
2829const std = @import("std");
29- const println = @import("util.zig").println;
30- const mem = std.mem;
31- const Allocator = mem.Allocator;
3230const curl = @import("curl");
33- const Easy = curl.Easy;
3431
3532pub fn main() !void {
3633 var gpa: std.heap.DebugAllocator(.{}) = .init;
@@ -39,38 +36,35 @@ pub fn main() !void {
3936
4037 const ca_bundle = try curl.allocCABundle(allocator);
4138 defer ca_bundle.deinit();
42- const easy = try Easy.init(.{
39+ const easy = try curl. Easy.init(.{
4340 .ca_bundle = ca_bundle,
4441 });
4542 defer easy.deinit();
43+
4644 {
47- println ("GET without write context" );
45+ std.debug.print ("GET without body\n", .{} );
4846 const resp = try easy.fetch("https://httpbin.org/anything", .{});
49-
5047 std.debug.print("Status code: {d}\n", .{resp.status_code});
5148 }
5249
5350 {
54- println("GET with fixed buffer" );
51+ std.debug.print("\nGET with fixed buffer as body\n", .{} );
5552 var buffer: [1024]u8 = undefined;
5653 var writer = std.Io.Writer.fixed(&buffer);
57- const resp = try easy.fetch("https://httpbin.org/anything", .{
58- .writer = &writer,
59- });
60- std.debug.print("Status code: {d}\nBody: {s}\n", .{
61- resp.status_code,
62- writer.buffered(),
63- });
54+ const resp = try easy.fetch("https://httpbin.org/anything", .{ .writer = &writer });
55+ std.debug.print("Status code: {d}\nBody: {s}\n", .{ resp.status_code, writer.buffered() });
6456 }
6557}
6658#+end_src
6759
60+ Check [[file:examples]] for more examples.
6861
69- See [[file:examples/basic.zig]], [[file:examples/advanced.zig]] for more usage.
62+ * Documentation
63+ See https://jiacai2050.github.io/zig-curl/
7064
7165* Installation
7266#+begin_src bash
73- zig fetch --save=curl https://github.com/jiacai2050/zig-curl/archive/refs/tags/${TAG}.zip
67+ zig fetch --save=curl https://github.com/jiacai2050/zig-curl/archive/refs/tags/${TAG}.zip
7468#+end_src
7569
7670The latest tag can be found on [[https://github.com/jiacai2050/zig-curl/releases/][release page]].
0 commit comments