From 58a16988c07c79a81598ace7b11975a6b4243a30 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 30 May 2026 02:32:29 -0700 Subject: [PATCH] replace zfetch with std.http client --- deps.zig | 21 +-------------------- licenses.txt | 3 --- src/cmd/zpm.zig | 15 ++++++++++++--- src/cmd/zpm/add.zig | 27 ++++++++++++++++++++------- src/lib.zig | 5 ++--- zig.mod | 1 - zigmod.lock | 3 --- 7 files changed, 35 insertions(+), 40 deletions(-) diff --git a/deps.zig b/deps.zig index a486b07566341ac9b198d516f67a2a7b177fe6fd..60abddb5eeecc8d15266c93e1c3c1ebbe4ee3211 100644 --- a/deps.zig +++ b/deps.zig @@ -56,8 +56,6 @@ pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step { } step.dependOn(&GitExactStep.create(b, "https://github.com/marlersoft/zigwin32", "ec98bb4d9eea532320a8551720a9e3ec6de64994").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/arqv-ini", "ab427a4de4f875eaa39ee56a29114fc020431546").step); - step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/iguanaTLS", "3450aaf3ca47986540e2b0258c2affc45af64ea2").step); - step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zfetch", "40d141bf7db81f05a83cce5f2edc4b14e41a5c34").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-ansi", "5f89211a749aef6bf518889c0467ceb24825c055").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-detect-license", "a1a066da88dab50873a56f0349dc12dc76542077").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-extras", "b3457b31a1d1ea2c19c5d0b007c903d3e80add40").step); @@ -75,7 +73,6 @@ pub fn fetch(exe: *std.Build.Step.Compile) *std.Build.Step { step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-time", "0f4db4c980146e4a3fc86a9a9070452a25ff9317").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-tracer", "3a5fdea4ffd387a53ac2a42fb503557cdbe20696").step); step.dependOn(&GitExactStep.create(b, "https://github.com/nektro/zig-yaml", "00e899bec815bc2b49c6e5a72a7cfeeda673e133").step); - step.dependOn(&GitExactStep.create(b, "https://github.com/truemedian/hzzp", "ab212bd208f0eb54d85861679677c5e3dc9bb543").step); step.dependOn(&GitExactStep.create(b, "https://github.com/madler/zlib", "da607da739fa6047df13e66a2af6b8bec7c2a498").step); step.dependOn(&GitExactStep.create(b, "https://github.com/yaml/libyaml", "2c891fc7a770e8ba2fec34fc6b545c672beb37e6").step); step.dependOn(&GitExactStep.create(b, "https://github.com/ziglibs/known-folders", "aa24df42183ad415d10bc0a33e6238c437fc0f59").step); @@ -199,11 +196,6 @@ pub const package_data = struct { .name = "ini", .entry = "/git/github.com/nektro/arqv-ini/ab427a4de4f875eaa39ee56a29114fc020431546/src/ini.zig", }; - pub var _csbnipaad8n7 = Package{ - .store = "/git/github.com/nektro/iguanaTLS/3450aaf3ca47986540e2b0258c2affc45af64ea2", - .name = "iguanaTLS", - .entry = "/git/github.com/nektro/iguanaTLS/3450aaf3ca47986540e2b0258c2affc45af64ea2/src/main.zig", - }; pub var _s84v9o48ucb0 = Package{ .store = "/git/github.com/nektro/zig-ansi/5f89211a749aef6bf518889c0467ceb24825c055", .name = "ansi", @@ -302,17 +294,6 @@ pub const package_data = struct { .entry = "/git/github.com/nektro/zig-yaml/00e899bec815bc2b49c6e5a72a7cfeeda673e133/yaml.zig", .deps = &[_]*Package{ &_8mdbh0zuneb0 }, }; - pub var _9k24gimke1an = Package{ - .store = "/git/github.com/truemedian/hzzp/ab212bd208f0eb54d85861679677c5e3dc9bb543", - .name = "hzzp", - .entry = "/git/github.com/truemedian/hzzp/ab212bd208f0eb54d85861679677c5e3dc9bb543/src/main.zig", - }; - pub var _ejw82j2ipa0e = Package{ - .store = "/git/github.com/nektro/zfetch/40d141bf7db81f05a83cce5f2edc4b14e41a5c34", - .name = "zfetch", - .entry = "/git/github.com/nektro/zfetch/40d141bf7db81f05a83cce5f2edc4b14e41a5c34/src/main.zig", - .deps = &[_]*Package{ &_9k24gimke1an, &_csbnipaad8n7 }, - }; pub var _0e2d06bb494b = Package{ .store = "/git/github.com/madler/zlib/da607da739fa6047df13e66a2af6b8bec7c2a498", .c_include_dirs = &.{ "" }, @@ -333,7 +314,7 @@ pub const package_data = struct { pub var _89ujp8gq842x = Package{ .name = "zigmod", .entry = "/../..//src/lib.zig", - .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_ejw82j2ipa0e, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_0k64oe2nuzvj, &_ocmr9rtohgcc, &_kscsl0145t7x, &_vph9l0hxpeze }, + .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm, &_f7dubzb7cyqe, &_0k64oe2nuzvj, &_ocmr9rtohgcc, &_kscsl0145t7x, &_vph9l0hxpeze }, }; pub var _root = Package{ }; diff --git a/licenses.txt b/licenses.txt index c7a4422460b22b4327c676c3190ce5815ba1884b..b03619ed05d999eb05a733931645a7804d16aaeb 100644 --- a/licenses.txt +++ b/licenses.txt @@ -3,8 +3,6 @@ MIT: - This - git https://github.com/marlersoft/zigwin32 - git https://github.com/nektro/arqv-ini -- git https://github.com/nektro/iguanaTLS -- git https://github.com/nektro/zfetch - git https://github.com/nektro/zig-ansi - git https://github.com/nektro/zig-detect-license - git https://github.com/nektro/zig-extras @@ -18,7 +16,6 @@ MIT: - git https://github.com/nektro/zig-time - git https://github.com/nektro/zig-tracer - git https://github.com/nektro/zig-yaml -- git https://github.com/truemedian/hzzp - git https://github.com/yaml/libyaml - git https://github.com/ziglibs/known-folders diff --git a/src/cmd/zpm.zig b/src/cmd/zpm.zig index 4a3cda5bd5cc137a6d8b73808c83150e98dfe432..d1ae76996154ef1199c4e84dea7b8e679020b468 100644 --- a/src/cmd/zpm.zig +++ b/src/cmd/zpm.zig @@ -1,7 +1,6 @@ const std = @import("std"); const string = []const u8; const gpa = std.heap.c_allocator; -const zfetch = @import("zfetch"); const extras = @import("extras"); const json = @import("json"); const nio = @import("nio"); @@ -58,9 +57,19 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { } pub fn server_fetch(url: string) !json.Document { - const req = try zfetch.Request.init(gpa, url, null); + var buf: [4096]u8 = @splat(0); + var client: std.http.Client = .{ .allocator = gpa }; + defer client.deinit(); + + var req = try client.open(.GET, try std.Uri.parse(url), .{ + .server_header_buffer = &buf, + .redirect_behavior = .not_allowed, + }); defer req.deinit(); - try req.do(.GET, null, null); + try req.send(); + try req.finish(); + try req.wait(); + if (req.response.status == .ok) return error.HttpExpected200; return json.parse(gpa, "", nio.AnyReadable.fromStd(&req.reader()), .{ .support_trailing_commas = true, .maximum_depth = 100 }); } diff --git a/src/cmd/zpm/add.zig b/src/cmd/zpm/add.zig index 01c500580a12dd5a59088c77774efe5ddfcb88cb..d0b6a8f4ef4e68275e79b2386b8c79bf297868c6 100644 --- a/src/cmd/zpm/add.zig +++ b/src/cmd/zpm/add.zig @@ -1,6 +1,5 @@ const std = @import("std"); const gpa = std.heap.c_allocator; -const zfetch = @import("zfetch"); const extras = @import("extras"); const nfs = @import("nfs"); @@ -43,19 +42,33 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { } } + var buf: [4096]u8 = @splat(0); + var client: std.http.Client = .{ .allocator = gpa }; + defer client.deinit(); + const has_zigdotmod = blk: { const _url = try std.mem.join(gpa, "/", &.{ found.git, "blob", "HEAD", "zig.mod" }); - const _req = try zfetch.Request.init(gpa, _url, null); + var _req = try client.open(.GET, try std.Uri.parse(_url), .{ + .server_header_buffer = &buf, + .redirect_behavior = .not_allowed, + }); defer _req.deinit(); - try _req.do(.GET, null, null); - break :blk @intFromEnum(_req.status) == 200; + try _req.send(); + try _req.finish(); + try _req.wait(); + break :blk _req.response.status == .ok; }; const has_zigmodyml = blk: { const _url = try std.mem.join(gpa, "/", &.{ found.git, "blob", "HEAD", "zigmod.yml" }); - const _req = try zfetch.Request.init(gpa, _url, null); + var _req = try client.open(.GET, try std.Uri.parse(_url), .{ + .server_header_buffer = &buf, + .redirect_behavior = .not_allowed, + }); defer _req.deinit(); - try _req.do(.GET, null, null); - break :blk @intFromEnum(_req.status) == 200; + try _req.send(); + try _req.finish(); + try _req.wait(); + break :blk _req.response.status == .ok; }; _, const file = try zigmod.ModFile.openFile(nfs.cwd(), .{ .mode = .read_write }); diff --git a/src/lib.zig b/src/lib.zig index 6e3273a0986950f0107aa1892abb94a1f3b0bfc6..af5863de017791b9f75c1b721580be190a4a2491 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const zfetch = @import("zfetch"); const extras = @import("extras"); const root = @import("root"); const build_options = root.build_options; @@ -18,11 +17,11 @@ pub const commands = struct { }; pub fn init() !void { - try zfetch.init(); + // } pub fn deinit() void { - zfetch.deinit(); + // } pub const Dep = @import("./util/dep.zig").Dep; diff --git a/zig.mod b/zig.mod index 02052f0e01e50232018274e41c59d72aefe570fd..8f88d3fb99ce88b4c8fdd952ae3cc73f4ca0b2d6 100644 --- a/zig.mod +++ b/zig.mod @@ -15,7 +15,6 @@ dependencies: license: MIT version: commit-aa24df42183ad415d10bc0a33e6238c437fc0f59 - src: git https://github.com/nektro/zig-licenses - - src: git https://github.com/nektro/zfetch - src: git https://github.com/nektro/zig-detect-license - src: git https://github.com/nektro/zig-inquirer - src: git https://github.com/nektro/arqv-ini diff --git a/zigmod.lock b/zigmod.lock index 955f05daafd160fc7ce3f8b29f38c2d1fcf7bab5..69317415c5f4696e2e73b80ffd741afcd43a8a2a 100644 --- a/zigmod.lock +++ b/zigmod.lock @@ -1,8 +1,6 @@ 2 git https://github.com/marlersoft/zigwin32 commit-ec98bb4d9eea532320a8551720a9e3ec6de64994 git https://github.com/nektro/arqv-ini commit-ab427a4de4f875eaa39ee56a29114fc020431546 -git https://github.com/nektro/iguanaTLS commit-3450aaf3ca47986540e2b0258c2affc45af64ea2 -git https://github.com/nektro/zfetch commit-40d141bf7db81f05a83cce5f2edc4b14e41a5c34 git https://github.com/nektro/zig-ansi commit-5f89211a749aef6bf518889c0467ceb24825c055 git https://github.com/nektro/zig-detect-license commit-a1a066da88dab50873a56f0349dc12dc76542077 git https://github.com/nektro/zig-extras commit-b3457b31a1d1ea2c19c5d0b007c903d3e80add40 @@ -20,7 +18,6 @@ git https://github.com/nektro/zig-sys-linux commit-f0b155d3627f8c19868be1b2f15d7 git https://github.com/nektro/zig-time commit-0f4db4c980146e4a3fc86a9a9070452a25ff9317 git https://github.com/nektro/zig-tracer commit-3a5fdea4ffd387a53ac2a42fb503557cdbe20696 git https://github.com/nektro/zig-yaml commit-00e899bec815bc2b49c6e5a72a7cfeeda673e133 -git https://github.com/truemedian/hzzp commit-ab212bd208f0eb54d85861679677c5e3dc9bb543 git https://github.com/madler/zlib tag-v1.3.2 git https://github.com/yaml/libyaml tag-0.2.5 git https://github.com/ziglibs/known-folders commit-aa24df42183ad415d10bc0a33e6238c437fc0f59 -- 2.54.0