summaryrefslogtreecommitdiff
path: root/src/Installation.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Installation.zig')
-rw-r--r--src/Installation.zig18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Installation.zig b/src/Installation.zig
index 4f7a48d..3c056b9 100644
--- a/src/Installation.zig
+++ b/src/Installation.zig
@@ -1,6 +1,6 @@
1const curl = @import("curl");
2const std = @import("std"); 1const std = @import("std");
3const xdg = @import("xdg"); 2const xdg = @import("xdg");
3const zelda = @import("zelda");
4const zup = @import("zup"); 4const zup = @import("zup");
5 5
6const Allocator = std.mem.Allocator; 6const Allocator = std.mem.Allocator;
@@ -135,13 +135,23 @@ pub fn isInstalled(allocator: Allocator, name: []const u8) !bool {
135pub fn getAvailableList(config: Config) !Installations { 135pub fn getAvailableList(config: Config) !Installations {
136 const allocator = config.allocator; 136 const allocator = config.allocator;
137 137
138 var json_str = try curl.easyDownload(allocator, "https://ziglang.org/download/index.json"); 138 var response = try zelda.get(allocator, "https://ziglang.org/download/index.json");
139 defer allocator.free(json_str); 139 defer response.deinit();
140
141 if (response.status_code.group() != .success) {
142 std.log.err("HTTP Error while getting Zig download index.json: {}", .{response.status_code});
143 return error.HttpError;
144 }
145
146 if (response.body == null) {
147 std.log.err("No body response while getting Zig download index.json", .{});
148 return error.HttpError;
149 }
140 150
141 var parser = std.json.Parser.init(allocator, false); 151 var parser = std.json.Parser.init(allocator, false);
142 defer parser.deinit(); 152 defer parser.deinit();
143 153
144 var vt = try parser.parse(json_str); 154 var vt = try parser.parse(response.body.?);
145 defer vt.deinit(); 155 defer vt.deinit();
146 156
147 if (vt.root != .Object) { 157 if (vt.root != .Object) {