diff --git a/http.zig b/http.zig index ff26d186e44f3d3f1a5233dc44c104305a1294a9..7de11da004061dd2ab36f6fb371606410b62389a 100644 --- a/http.zig +++ b/http.zig @@ -213,6 +213,7 @@ pub fn open(allocator: std.mem.Allocator, method: Method, input: []const u8) !Cl .stream = conn, .writer = bufw, .reader = .init(conn), + .status = @enumFromInt(0), .headers_raw = "", }; } @@ -222,6 +223,7 @@ pub const ClientRequest = struct { stream: net.Stream, writer: nio.BufferedWriter(4096, net.Stream), reader: nio.BufferedReader(4096, net.Stream), + status: Status, headers_raw: []const u8, pub fn close(req: *const ClientRequest, allocator: std.mem.Allocator) void { @@ -257,6 +259,7 @@ pub const ClientRequest = struct { if (status.phrase()) |phrase| if (!std.mem.eql(u8, actual_phrase, phrase)) return error.Bad; + req.status = status; var headers_list = std.ArrayList(u8).init(req.allocator); errdefer headers_list.deinit(); diff --git a/test.zig b/test.zig index 72c2fd05b4497c877af98aaad4358ea859a155bf..b64d2d09c83b596bb4355f69717d2be23f0ce226 100644 --- a/test.zig +++ b/test.zig @@ -23,6 +23,7 @@ fn httpbinMethodGet(comptime scheme: Scheme) !void { defer req.close(allocator); try req.writeUA(); try req.send(); + try expect(req.status).toEqual(.ok); const doc = try json.parse(allocator, "httpbinMethodGet", &req, .{ .support_trailing_commas = false, .maximum_depth = 2 }); defer doc.deinit(allocator); doc.acquire();