From d17436932d070d366333c250fd5f8307bf886b80 Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Sun, 21 Apr 2024 17:38:06 +0200 Subject: [PATCH] fix test-sendfile (std.http use) --- src/tests/test_sendfile.zig | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/tests/test_sendfile.zig b/src/tests/test_sendfile.zig index d3686961..8b16a8a4 100644 --- a/src/tests/test_sendfile.zig +++ b/src/tests/test_sendfile.zig @@ -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(); }