Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Feb 28, 2024
1 parent c5feecc commit e08cca6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ jobs:
version: master
- name: Install deps
run: |
sudo apt update && sudo apt install -y valgrind libcurl4-openssl-dev
make prepare
sudo apt update && sudo apt install -y valgrind
- name: Run tests
run: |
make test
Expand Down Expand Up @@ -60,9 +59,6 @@ jobs:
- uses: goto-bus-stop/setup-zig@v1
with:
version: master
- name: Install deps
run: |
make prepare
- name: Run examples
run: |
make run
14 changes: 9 additions & 5 deletions examples/advanced.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ fn put_with_custom_header(allocator: Allocator, easy: Easy) !void {
try easy.set_method(.PUT);
try easy.set_verbose(true);
try easy.set_post_fields(body);
const resp_buf = try easy.alloc_response_buffer();

const resp = try easy.perform();
var resp = try easy.perform();
resp.body = resp_buf;
defer resp.deinit();

std.debug.print("Status code: {d}\nBody: {s}\n", .{
resp.status_code,
resp.body.items,
resp.body.?.items,
});

const parsed = try std.json.parseFromSlice(Response, allocator, resp.body.items, .{
const parsed = try std.json.parseFromSlice(Response, allocator, resp.body.?.items, .{
.ignore_unknown_fields = true,
});
defer parsed.deinit();
Expand Down Expand Up @@ -94,11 +96,13 @@ fn post_mutli_part(easy: Easy) !void {
try easy.set_method(.PUT);
try easy.set_multi_part(multi_part);
try easy.set_verbose(true);
const resp_buf = try easy.alloc_response_buffer();

const resp = try easy.perform();
var resp = try easy.perform();
resp.body = resp_buf;
defer resp.deinit();

std.debug.print("resp:{s}\n", .{resp.body.items});
std.debug.print("resp:{s}\n", .{resp.body.?.items});
}

pub fn main() !void {
Expand Down
2 changes: 1 addition & 1 deletion src/easy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub fn perform(self: Self) !Response {
};
}

fn alloc_response_buffer(self: Self) !*Buffer {
pub fn alloc_response_buffer(self: Self) !*Buffer {
const buf = try self.allocator.create(Buffer);
buf.*.allocator = self.allocator;
buf.*.items = &[_]u8{};
Expand Down

0 comments on commit e08cca6

Please sign in to comment.