mirror of
https://github.com/ziglang/zig.git
synced 2026-01-06 05:25:10 +00:00
std.Io.Reader: fix appendRemainingUnlimited
Now it avoids mutating `r` unnecessarily, allowing the `ending` Reader to work.
This commit is contained in:
parent
b757d7f941
commit
18c4a500b6
@ -367,8 +367,11 @@ pub fn appendRemainingUnlimited(
|
||||
const buffer_contents = r.buffer[r.seek..r.end];
|
||||
try list.ensureUnusedCapacity(gpa, buffer_contents.len + bump);
|
||||
list.appendSliceAssumeCapacity(buffer_contents);
|
||||
r.seek = 0;
|
||||
r.end = 0;
|
||||
// If statement protects `ending`.
|
||||
if (r.end != 0) {
|
||||
r.seek = 0;
|
||||
r.end = 0;
|
||||
}
|
||||
// From here, we leave `buffer` empty, appending directly to `list`.
|
||||
var writer: Writer = .{
|
||||
.buffer = undefined,
|
||||
|
||||
@ -414,7 +414,8 @@ test "general client/server API coverage" {
|
||||
log.info("{f} {t} {s}", .{ request.head.method, request.head.version, request.head.target });
|
||||
|
||||
const gpa = std.testing.allocator;
|
||||
const body = try (try request.readerExpectContinue(&.{})).allocRemaining(gpa, .unlimited);
|
||||
const reader = (try request.readerExpectContinue(&.{}));
|
||||
const body = try reader.allocRemaining(gpa, .unlimited);
|
||||
defer gpa.free(body);
|
||||
|
||||
if (mem.startsWith(u8, request.head.target, "/get")) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user