diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ad5fd54..300e9f2 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,6 +29,9 @@ jobs: - name: Install deps run: | sudo apt update && sudo apt install -y valgrind libcurl4-openssl-dev + - name: Run tests + run: | + make build test - name: Run examples run: | make run-examples diff --git a/examples/advanced.zig b/examples/advanced.zig index 3b97a9e..14ee5d0 100644 --- a/examples/advanced.zig +++ b/examples/advanced.zig @@ -44,7 +44,7 @@ fn put_with_custom_header(allocator: Allocator, easy: Easy) !void { const resp = try easy.do(req); defer resp.deinit(); - std.debug.print("Status code: {d}\nBody: [{s}]\n", .{ + std.debug.print("Status code: {d}\nBody: {s}\n", .{ resp.status_code, resp.body.items, }); @@ -82,9 +82,7 @@ fn put_with_custom_header(allocator: Allocator, easy: Easy) !void { } } -fn post_mutli_part(allocator: Allocator, easy: Easy) !void { - _ = allocator; - +fn post_mutli_part(easy: Easy) !void { const multi_part = try easy.add_multi_part(); try multi_part.add_part("foo", .{ .memory = "hello foo" }); try multi_part.add_part("bar", .{ .memory = "hello bar" }); diff --git a/src/easy.zig b/src/easy.zig index 6ee1c3e..5da7af1 100644 --- a/src/easy.zig +++ b/src/easy.zig @@ -187,9 +187,14 @@ pub const MultiPart = struct { allocator: Allocator, pub const DataSource = union(enum) { - memory: []const u8, + /// Set a mime part's body content from memory data. + /// Data will get copied when send request. + /// Setting large data is memory consuming: one might consider using `data_callback` in such a case. + data: []const u8, + /// Set a mime part's body data from a file contents. file: []const u8, - // read_callback : + // TODO: https://curl.se/libcurl/c/curl_mime_data_cb.html + // data_callback: u8, }; pub fn deinit(self: @This()) void {