| author | |
| committer | |
| log | abd76938cb8455891c5a69c33edb7060f42001a3 |
| tree | 879cb79638c8ef3e9a8ed790d255c24073551360 |
| parent | 9e5048c3a5be479d9ad72d1d004d385f2fdc8615 |
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,8 +367,11 @@ pub fn appendRemainingUnlimited( |
| 367 | const buffer_contents = r.buffer[r.seek..r.end]; | 367 | const buffer_contents = r.buffer[r.seek..r.end]; |
| 368 | try list.ensureUnusedCapacity(gpa, buffer_contents.len + bump); | 368 | try list.ensureUnusedCapacity(gpa, buffer_contents.len + bump); |
| 369 | list.appendSliceAssumeCapacity(buffer_contents); | 369 | list.appendSliceAssumeCapacity(buffer_contents); |
| 370 | r.seek = 0; | 370 | // If statement protects `ending`. |
| 371 | r.end = 0; | 371 | if (r.end != 0) { |
| 372 | r.seek = 0; | ||
| 373 | r.end = 0; | ||
| 374 | } | ||
| 372 | // From here, we leave `buffer` empty, appending directly to `list`. | 375 | // From here, we leave `buffer` empty, appending directly to `list`. |
| 373 | var writer: Writer = .{ | 376 | var writer: Writer = .{ |
| 374 | .buffer = undefined, | 377 | .buffer = undefined, |
lib/std/http/test.zig+2-1| ... | @@ -414,7 +414,8 @@ test "general client/server API coverage" { | ... | @@ -414,7 +414,8 @@ test "general client/server API coverage" { |
| 414 | log.info("{f} {t} {s}", .{ request.head.method, request.head.version, request.head.target }); | 414 | log.info("{f} {t} {s}", .{ request.head.method, request.head.version, request.head.target }); |
| 415 | 415 | ||
| 416 | const gpa = std.testing.allocator; | 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 | defer gpa.free(body); | 419 | defer gpa.free(body); |
| 419 | 420 | ||
| 420 | if (mem.startsWith(u8, request.head.target, "/get")) { | 421 | if (mem.startsWith(u8, request.head.target, "/get")) { |