# zig-curl **Repository Path**: candicandi/zig-curl ## Basic Information - **Project Name**: zig-curl - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-24 - **Last Updated**: 2025-08-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #+TITLE: zig-curl #+DATE: 2023-09-16T23:16:15+0800 #+LASTMOD: 2025-08-24T10:24:23+0800 #+OPTIONS: toc:nil num:nil #+STARTUP: content [[https://img.shields.io/badge/zig%20version-0.14.0-blue.svg]] [[https://img.shields.io/badge/zig%20version-master-blue.svg]] [[https://github.com/jiacai2050/zig-curl/actions/workflows/CI.yml][https://github.com/jiacai2050/zig-curl/actions/workflows/CI.yml/badge.svg]] [[https://ci.codeberg.org/repos/13257][https://ci.codeberg.org/api/badges/13257/status.svg]] Zig bindings for [[https://curl.haxx.se/libcurl/][libcurl]], a free and easy-to-use client-side URL transfer library. The vendored libraries consist of: | Library | Version | |---------+---------| | libcurl | [[https://github.com/curl/curl/tree/curl-8_8_0][8.8.0]] | | zlib | [[https://github.com/madler/zlib/tree/v1.3.1][1.3.1]] | | mbedtls | [[https://github.com/Mbed-TLS/mbedtls/tree/v3.6.0][3.6.0]] | * Usage #+begin_src bash :results verbatim :exports results :wrap src zig cat examples/hello.zig #+end_src #+RESULTS: #+begin_src zig const std = @import("std"); const curl = @import("curl"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer if (gpa.deinit() != .ok) @panic("leak"); const allocator = gpa.allocator(); const ca_bundle = try curl.allocCABundle(allocator); defer ca_bundle.deinit(); const easy = try curl.Easy.init(.{ .ca_bundle = ca_bundle, }); defer easy.deinit(); var writer = curl.ResizableResponseWriter.init(allocator); defer writer.deinit(); const resp = try easy.fetch("https://httpbin.org/anything", .{ .response_writer = writer.asAny(), }); std.debug.print("Status code: {d}\nBody: {s}\n", .{ resp.status_code, writer.asSlice(), }); } #+end_src See [[file:examples/basic.zig]], [[file:examples/advanced.zig]] for more usage. * Installation #+begin_src bash zig fetch --save=curl https://github.com/jiacai2050/zig-curl/archive/refs/tags/${TAG}.zip #+end_src The latest tag can be found on [[https://github.com/jiacai2050/zig-curl/releases/][release page]]. After fetch, import =curl= like this in your =build.zig=: #+begin_src zig const dep_curl = b.dependency("curl", .{}); exe.root_module.addImport("curl", dep_curl.module("curl")); exe.linkLibC(); #+end_src This library will link to a vendored libcurl by default, you can disable it and link to system-wide with this #+begin_src zig const dep_curl = b.dependency("curl", .{ .link_vendor = false }); exe.linkSystemLibrary("curl"); exe.linkLibC(); #+end_src * License [[file:LICENSE][MIT]]