Skip to content

Commit

Permalink
fix test-sendfile (std.http use)
Browse files Browse the repository at this point in the history
  • Loading branch information
renerocksai committed Apr 21, 2024
1 parent 0e43f56 commit d174369
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/tests/test_sendfile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ var read_len: ?usize = null;
const testfile = @embedFile("testfile.txt");

fn makeRequest(a: std.mem.Allocator, url: []const u8) !void {
const uri = try std.Uri.parse(url);

var h = std.http.Headers{ .allocator = a };
defer h.deinit();

var http_client: std.http.Client = .{ .allocator = a };
defer http_client.deinit();

var req = try http_client.open(.GET, uri, h, .{});
defer req.deinit();

try req.send(.{});
try req.wait();
read_len = try req.readAll(&buffer);
var response = std.ArrayList(u8).init(a);
defer response.deinit();
_ = try http_client.fetch(.{
.location = .{ .url = url },
.response_storage = .{ .dynamic = &response },
});
read_len = response.items.len;
@memcpy(buffer[0..read_len.?], response.items);

zap.stop();
}
Expand Down

0 comments on commit d174369

Please sign in to comment.