Skip to content

Commit

Permalink
fix: apply latest master changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hendriknielaender committed Mar 12, 2024
1 parent 22204ae commit 68588a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/download.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/install.zig
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ 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();

// 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], .{});
Expand Down
7 changes: 4 additions & 3 deletions src/versions.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ 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();

// 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], .{});
Expand Down

0 comments on commit 68588a5

Please sign in to comment.