zig 0.12.0: need to dupe the headers

This commit is contained in:
Emil Lerch 2024-05-06 16:20:03 -07:00
parent 17661b9da2
commit 1053c8f002
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -96,7 +96,8 @@ fn handleRequest(allocator: std.mem.Allocator, response: *interface.ZigResponse)
},
);
}
response.headers = ul_response.headers;
response.headers = try allocator.dupe(std.http.Header, ul_response.headers);
// response.headers = ul_response.headers;
// Anything manually written goes first
try response_writer.writeAll(ul_response.body.items);
// Now we right the official body (response from handler)
@ -127,7 +128,7 @@ pub fn main() !u8 {
register(testHandler);
return 0;
}
fn testHandler(allocator: std.mem.Allocator, event_data: []const u8, context: @import("universal_lambda_interface").Context) ![]const u8 {
fn testHandler(allocator: std.mem.Allocator, event_data: []const u8, context: universal_lambda_interface.Context) ![]const u8 {
context.headers = &.{.{ .name = "X-custom-foo", .value = "bar" }};
try context.writeAll(event_data);
return std.fmt.allocPrint(allocator, "{d}", .{context.request.headers.len});