From 17af53554e1362f9632aff592afcba11190c94b1 Mon Sep 17 00:00:00 2001 From: Ryo Ota Date: Mon, 17 Apr 2023 19:33:25 +0900 Subject: [PATCH] HTTP client and server send "0\r\n\r\n" when chunked encoding --- lib/std/http/Client.zig | 2 +- lib/std/http/Server.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/http/Client.zig b/lib/std/http/Client.zig index 010c557f87..41f199a094 100644 --- a/lib/std/http/Client.zig +++ b/lib/std/http/Client.zig @@ -856,7 +856,7 @@ pub const Request = struct { /// Finish the body of a request. This notifies the server that you have no more data to send. pub fn finish(req: *Request) !void { switch (req.headers.transfer_encoding) { - .chunked => req.connection.data.conn.writeAll("0\r\n") catch |err| { + .chunked => req.connection.data.conn.writeAll("0\r\n\r\n") catch |err| { req.client.last_error = .{ .write = err }; return error.WriteFailed; }, diff --git a/lib/std/http/Server.zig b/lib/std/http/Server.zig index 85fbf25265..1ecb8fbd69 100644 --- a/lib/std/http/Server.zig +++ b/lib/std/http/Server.zig @@ -517,7 +517,7 @@ pub const Response = struct { /// Finish the body of a request. This notifies the server that you have no more data to send. pub fn finish(res: *Response) !void { switch (res.headers.transfer_encoding) { - .chunked => try res.connection.writeAll("0\r\n"), + .chunked => try res.connection.writeAll("0\r\n\r\n"), .content_length => |len| if (len != 0) return error.MessageNotCompleted, .none => {}, }