From 33226c20c41e3fe2de3330b6692c90bc4818b119 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Tue, 15 Nov 2022 13:55:07 +0200 Subject: Don't download the archive to a file --- src/http.zig | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 src/http.zig (limited to 'src/http.zig') diff --git a/src/http.zig b/src/http.zig deleted file mode 100644 index bb3b3ac..0000000 --- a/src/http.zig +++ /dev/null @@ -1,23 +0,0 @@ -const std = @import("std"); -const zelda = @import("zelda"); - -const Allocator = std.mem.Allocator; -const File = std.fs.File; - -// TODO: zelda should be able to do this internally so I wouldn't have to allocate memory for the -// file -pub fn downloadToFile(allocator: Allocator, file: *File, url: []const u8) !void { - var response = try zelda.get(allocator, url); - defer response.deinit(); - - if (response.status_code.group() != .success) { - std.log.err("HTTP Error: {}", .{response.status_code}); - return error.HttpError; - } - - if (response.body) |body| { - try file.writer().writeAll(body); - } else { - std.log.warn("Downloaded nothing from {s}...", .{url}); - } -} -- cgit v1.2.3