| author | |
| committer | |
| log | ddef683fcb321882cc912090a25c12bc8705ff55 |
| tree | d06228cf7b54f4610d498fe7a7d6c6fda97b0b65 |
| parent | 3817c7382b66bbac0c8f7ea4ff45685bb41b6a63 |
| signature |
2 files changed, 6 insertions(+), 4 deletions(-)
lib/std/http/Server.zig+4-4| ... | ... | @@ -458,6 +458,10 @@ pub const Response = struct { |
| 458 | 458 | try w.print("{}", .{res.headers}); |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | if (res.request.method == .HEAD) { | |
| 462 | res.transfer_encoding = .none; | |
| 463 | } | |
| 464 | ||
| 461 | 465 | try w.writeAll("\r\n"); |
| 462 | 466 | |
| 463 | 467 | try buffered.flush(); |
| ... | ... | @@ -520,10 +524,6 @@ pub const Response = struct { |
| 520 | 524 | res.request.parser.done = true; |
| 521 | 525 | } |
| 522 | 526 | |
| 523 | if (res.request.method == .HEAD) { | |
| 524 | res.request.parser.done = true; | |
| 525 | } | |
| 526 | ||
| 527 | 527 | if (!res.request.parser.done) { |
| 528 | 528 | if (res.request.transfer_compression) |tc| switch (tc) { |
| 529 | 529 | .compress => return error.CompressionNotSupported, |
test/standalone/http.zig+2| ... | ... | @@ -55,6 +55,8 @@ fn handleRequest(res: *Server.Response) !void { |
| 55 | 55 | try res.writeAll("Hello, "); |
| 56 | 56 | try res.writeAll("World!\n"); |
| 57 | 57 | try res.finish(); |
| 58 | } else { | |
| 59 | try testing.expectEqual(res.writeAll("errors"), error.NotWriteable); | |
| 58 | 60 | } |
| 59 | 61 | } else if (mem.startsWith(u8, res.request.target, "/large")) { |
| 60 | 62 | res.transfer_encoding = .{ .content_length = 14 * 1024 + 14 * 10 }; |