diff --git a/src/download.zig b/src/download.zig index 36279d8..6878f53 100644 --- a/src/download.zig +++ b/src/download.zig @@ -87,7 +87,10 @@ fn downloadAndExtract(allocator: std.mem.Allocator, uri: std.Uri, version_path: const sendOptions = std.http.Client.Request.SendOptions{}; - var req = try client.open(.GET, uri, .{ .allocator = allocator }, .{}); + // Read the response body with 256kb buffer allocation + var headerBuffer: [262144]u8 = undefined; // 256 * 1024 = 262kb + + var req = try client.open(.GET, uri, .{ .server_header_buffer = &headerBuffer }); defer req.deinit(); try req.send(sendOptions); diff --git a/src/install.zig b/src/install.zig index 0b6b288..cec2b3f 100644 --- a/src/install.zig +++ b/src/install.zig @@ -37,8 +37,11 @@ fn fetchVersionData(allocator: Allocator, requested_version: []const u8, sub_key const sendOptions = std.http.Client.Request.SendOptions{}; + // Read the response body with 256kb buffer allocation + var buffer: [262144]u8 = undefined; // 256 * 1024 = 262kb + // Make the HTTP request - var req = try client.open(.GET, uri, .{ .allocator = allocator }, .{}); + var req = try client.open(.GET, uri, .{ .server_header_buffer = &buffer }); defer req.deinit(); try req.send(sendOptions); try req.wait(); @@ -46,8 +49,6 @@ fn fetchVersionData(allocator: Allocator, requested_version: []const u8, sub_key // Check if request was successful try std.testing.expect(req.response.status == .ok); - // Read the response body with 256kb buffer allocation - var buffer: [262144]u8 = undefined; // 256 * 1024 = 262kb const read_len = try req.readAll(buffer[0..]); const parsed = try std.json.parseFromSlice(std.json.Value, allocator, buffer[0..read_len], .{}); diff --git a/src/versions.zig b/src/versions.zig index c7c7135..5f7c4b9 100644 --- a/src/versions.zig +++ b/src/versions.zig @@ -10,8 +10,11 @@ pub fn list(allocator: std.mem.Allocator) !std.ArrayList([]const u8) { const sendOptions = std.http.Client.Request.SendOptions{}; + // Read the response body with 256kb buffer allocation + var buffer: [262144]u8 = undefined; // 256 * 1024 = 262kb + // Make the HTTP request - var req = try client.open(.GET, uri, .{ .allocator = allocator }, .{}); + var req = try client.open(.GET, uri, .{ .server_header_buffer = &buffer }); defer req.deinit(); try req.send(sendOptions); try req.wait(); @@ -19,8 +22,6 @@ pub fn list(allocator: std.mem.Allocator) !std.ArrayList([]const u8) { // Check if request was successful try std.testing.expect(req.response.status == .ok); - // Read the response body with 256kb buffer allocation - var buffer: [262144]u8 = undefined; // 256 * 1024 = 262kb const read_len = try req.readAll(buffer[0..]); const parsed = try std.json.parseFromSlice(std.json.Value, allocator, buffer[0..read_len], .{});