mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.http: allow fetching with no payload
When a POST, PUT, or PATCH request is sent by Client.fetch without a payload an assert fails in `sendBodiless` as these methods are expected to have a body. However, the HTTP spec does not _require_ them to have a body.
This commit is contained in:
parent
3f2cf1c002
commit
6bafd2d706
1 changed files with 5 additions and 0 deletions
|
|
@ -1803,6 +1803,11 @@ pub fn fetch(client: *Client, options: FetchOptions) FetchError!FetchResult {
|
|||
try body.writer.writeAll(payload);
|
||||
try body.end();
|
||||
try req.connection.?.flush();
|
||||
} else if (http.Method.requestHasBody(req.method)) {
|
||||
req.transfer_encoding = .{ .content_length = 0 };
|
||||
var body = try req.sendBodyUnflushed(&.{});
|
||||
try body.end();
|
||||
try req.connection.?.flush();
|
||||
} else {
|
||||
try req.sendBodiless();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue