diff --git a/src/network/HttpClient.zig b/src/network/HttpClient.zig index d53e6eeec..7568bd02c 100644 --- a/src/network/HttpClient.zig +++ b/src/network/HttpClient.zig @@ -1457,6 +1457,10 @@ const SyncContext = struct { const body_len = transfer.bodyLen(); const allocator = try self.bodyAllocator(body_len); + if (body_len > 0) { + try self.body.ensureTotalCapacityPrecise(allocator, body_len); + } + if (self.options.copy_headers) { var it = transfer.responseHeaderIterator(); while (it.next()) |hdr| { @@ -1466,10 +1470,6 @@ const SyncContext = struct { }); } } - - if (body_len > 0) { - try self.body.ensureTotalCapacityPrecise(allocator, body_len); - } return .proceed; }