From d646e7d74311bb3ac477d7ede3ccc3d645f7849d Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 5 Feb 2026 01:19:35 -0800 Subject: [PATCH] add httpbinUserAgent test --- test.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test.zig b/test.zig index d2987c845254c2522c2fb2ba403d209e1ce12cb9..a9d102111c4fef916bb6598d4f7de09bbbe80f18 100644 --- a/test.zig +++ b/test.zig @@ -19,6 +19,7 @@ test { try httpbinMethod(.http, .POST); } test { try httpbinMethod(.http, .PUT); } test { try httpbinMethod(.http, .PATCH); } test { try httpbinMethod(.http, .DELETE); } +test { try httpbinUserAgent(.http); } // zig fmt: on fn httpbinMethod(comptime scheme: Scheme, comptime method: http.Method) !void { @@ -35,3 +36,17 @@ fn httpbinMethod(comptime scheme: Scheme, comptime method: http.Method) !void { defer doc.release(); try expect(doc.root.object().getS("url")).toEqualString(url); } +fn httpbinUserAgent(comptime scheme: Scheme) !void { + const allocator = std.testing.allocator; + const url = @tagName(scheme) ++ "://httpbin.org/user-agent"; + var req = try http.open(allocator, .GET, url); + defer req.close(allocator); + try req.writeUA(); + try req.send(); + try expect(req.status).toEqual(.ok); + const doc = try json.parse(allocator, "httpbinMethod", &req, .{ .support_trailing_commas = false, .maximum_depth = 2 }); + defer doc.deinit(allocator); + doc.acquire(); + defer doc.release(); + try expect(doc.root.object().getS("user-agent")).toEqualString("WIP https://github.com/nektro/zig-net-http"); +} -- 2.54.0