authorgravatar for nwtgck@nwtgck.orgRyo Ota <nwtgck@nwtgck.org> 2023-04-17 19:33:25+09:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-04-17 13:33:25+03:00
log17af53554e1362f9632aff592afcba11190c94b1
tree01ae21c25cd09381114201aa4b75bb50d5536ba5
parent1fb0b5a04429f06d75e22223765fa8723318489e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

HTTP client and server send "0\r\n\r\n" when chunked encoding


2 files changed, 2 insertions(+), 2 deletions(-)

lib/std/http/Client.zig+1-1
...@@ -856,7 +856,7 @@ pub const Request = struct {...@@ -856,7 +856,7 @@ pub const Request = struct {
856 /// Finish the body of a request. This notifies the server that you have no more data to send.856 /// Finish the body of a request. This notifies the server that you have no more data to send.
857 pub fn finish(req: *Request) !void {857 pub fn finish(req: *Request) !void {
858 switch (req.headers.transfer_encoding) {858 switch (req.headers.transfer_encoding) {
859 .chunked => req.connection.data.conn.writeAll("0\r\n") catch |err| {859 .chunked => req.connection.data.conn.writeAll("0\r\n\r\n") catch |err| {
860 req.client.last_error = .{ .write = err };860 req.client.last_error = .{ .write = err };
861 return error.WriteFailed;861 return error.WriteFailed;
862 },862 },
lib/std/http/Server.zig+1-1
...@@ -517,7 +517,7 @@ pub const Response = struct {...@@ -517,7 +517,7 @@ pub const Response = struct {
517 /// Finish the body of a request. This notifies the server that you have no more data to send.517 /// Finish the body of a request. This notifies the server that you have no more data to send.
518 pub fn finish(res: *Response) !void {518 pub fn finish(res: *Response) !void {
519 switch (res.headers.transfer_encoding) {519 switch (res.headers.transfer_encoding) {
520 .chunked => try res.connection.writeAll("0\r\n"),520 .chunked => try res.connection.writeAll("0\r\n\r\n"),
521 .content_length => |len| if (len != 0) return error.MessageNotCompleted,521 .content_length => |len| if (len != 0) return error.MessageNotCompleted,
522 .none => {},522 .none => {},
523 }523 }