Skip to content

Commit

Permalink
add data_cb comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Sep 20, 2023
1 parent bea2835 commit a1f6134
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions examples/advanced.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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" });
Expand Down
9 changes: 7 additions & 2 deletions src/easy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a1f6134

Please sign in to comment.