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

This commit is contained in:
Ryo Ota 2023-04-17 19:33:25 +09:00 committed by GitHub
parent 1fb0b5a044
commit 17af53554e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -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;
},

View File

@ -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 => {},
}