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, 4 insertions, 14 deletions
diff --git a/src/Installation.zig b/src/Installation.zig
index 3c056b9..4f7a48d 100644
--- a/src/Installation.zig
+++ b/src/Installation.zig
@@ -1,6 +1,6 @@
1const curl = @import("curl");
1const std = @import("std"); 2const std = @import("std");
2const xdg = @import("xdg"); 3const 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,23 +135,13 @@ 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 response = try zelda.get(allocator, "https://ziglang.org/download/index.json"); 138 var json_str = try curl.easyDownload(allocator, "https://ziglang.org/download/index.json");
139 defer response.deinit(); 139 defer allocator.free(json_str);
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 }
150 140
151 var parser = std.json.Parser.init(allocator, false); 141 var parser = std.json.Parser.init(allocator, false);
152 defer parser.deinit(); 142 defer parser.deinit();
153 143
154 var vt = try parser.parse(response.body.?); 144 var vt = try parser.parse(json_str);
155 defer vt.deinit(); 145 defer vt.deinit();
156 146
157 if (vt.root != .Object) { 147 if (vt.root != .Object) {