From 3710fda82ef98929af141feaa57ccafd9d7a7d9d Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Tue, 18 Jul 2023 13:48:36 +0000 Subject: added status message to error response --- src/main.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.zig b/src/main.zig index 335e80c..3739218 100644 --- a/src/main.zig +++ b/src/main.zig @@ -54,10 +54,10 @@ fn serve_file(res: *std.http.Server.Response, file: std.fs.File, md: std.fs.File fn serve_error(res: *std.http.Server.Response, status: std.http.Status) !void { res.status = status; - const msg = - \\ error! - ; - res.transfer_encoding = . { .content_length = msg.len }; - try res.do(); - _ = try res.write(msg); + res.transfer_encoding = .chunked; + try res.do(); + const phrase = status.phrase() orelse "error!"; + try std.fmt.format(res.writer(), + \\ {s} + , .{phrase}); } -- cgit v1.2.3-ZIG