From da9eae4876fcea7a4c8fb7bd8460d5ddcb78c2c0 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Sat, 24 Jul 2021 00:23:06 -0700 Subject: [PATCH] add headers to returned response --- src/awshttp.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/awshttp.zig b/src/awshttp.zig index e4b3115..045a8cf 100644 --- a/src/awshttp.zig +++ b/src/awshttp.zig @@ -84,10 +84,16 @@ const HttpRequest = struct { const HttpResult = struct { response_code: u16, // actually 3 digits can fit in u10 body: []const u8, + headers: []Header, allocator: *std.mem.Allocator, pub fn deinit(self: HttpResult) void { self.allocator.free(self.body); + for (self.headers) |h| { + self.allocator.free(h.name); + self.allocator.free(h.value); + } + self.allocator.free(self.headers); httplog.debug("http result deinit complete", .{}); return; } @@ -458,6 +464,7 @@ pub const AwsHttp = struct { const rc = HttpResult{ .response_code = context.response_code.?, .body = final_body, + .headers = context.headers.?.toOwnedSlice(), .allocator = self.allocator, }; return rc;