move body ensure capacity before optional header copy

This commit is contained in:
Muki Kiboigo authored and Karl Seguin committed 2026-09-29 07:49:07 +08:00
1 parent 1dfd8ef89e
commit 93ef6eb7bf
1 file changed
+4 -4
+4 -4
View File
@@ -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;
}