| author | |
| committer | |
| log | 18c4a500b6fd93e3e48ccaf413f2e9f90730f069 |
| tree | 7111dba0d59f35f92a3c5d972892274d9da21b59 |
| parent | b757d7f941e243d4a40fbba90e51a9f514350320 |
Now it avoids mutating `r` unnecessarily, allowing the `ending` Reader
to work.2 files changed, 7 insertions(+), 3 deletions(-)
lib/std/Io/Reader.zig+5-2| ... | ... | @@ -367,8 +367,11 @@ pub fn appendRemainingUnlimited( |
| 367 | 367 | const buffer_contents = r.buffer[r.seek..r.end]; |
| 368 | 368 | try list.ensureUnusedCapacity(gpa, buffer_contents.len + bump); |
| 369 | 369 | list.appendSliceAssumeCapacity(buffer_contents); |
| 370 | r.seek = 0; | |
| 371 | r.end = 0; | |
| 370 | // If statement protects `ending`. | |
| 371 | if (r.end != 0) { | |
| 372 | r.seek = 0; | |
| 373 | r.end = 0; | |
| 374 | } | |
| 372 | 375 | // From here, we leave `buffer` empty, appending directly to `list`. |
| 373 | 376 | var writer: Writer = .{ |
| 374 | 377 | .buffer = undefined, |
lib/std/http/test.zig+2-1| ... | ... | @@ -414,7 +414,8 @@ test "general client/server API coverage" { |
| 414 | 414 | log.info("{f} {t} {s}", .{ request.head.method, request.head.version, request.head.target }); |
| 415 | 415 | |
| 416 | 416 | const gpa = std.testing.allocator; |
| 417 | const body = try (try request.readerExpectContinue(&.{})).allocRemaining(gpa, .unlimited); | |
| 417 | const reader = (try request.readerExpectContinue(&.{})); | |
| 418 | const body = try reader.allocRemaining(gpa, .unlimited); | |
| 418 | 419 | defer gpa.free(body); |
| 419 | 420 | |
| 420 | 421 | if (mem.startsWith(u8, request.head.target, "/get")) { |