aboutsummaryrefslogtreecommitdiff
path: root/src/http_client_async.zig
diff options
context:
space:
mode:
authorGravatar Ciro Spaciari <ciro.spaciari@gmail.com> 2023-09-04 16:26:49 -0300
committerGravatar GitHub <noreply@github.com> 2023-09-04 12:26:49 -0700
commit2d80f94edafe09329b027424b32908632694553d (patch)
treee7de3a4fa31096a26d4dda37eedf18cb51a902a1 /src/http_client_async.zig
parent18767906db0dd29b2d898f84a023d403c3084d6e (diff)
downloadbun-2d80f94edafe09329b027424b32908632694553d.tar.gz
bun-2d80f94edafe09329b027424b32908632694553d.tar.zst
bun-2d80f94edafe09329b027424b32908632694553d.zip
fix(HTMLRewriter) buffer response before transform (#4418)
* html rewriter response buffering * pipe the data when marked as used * fix empty response * add some fetch tests * deinit parent stream * fix decompression * keep byte_reader alive * update builds * remove nonsense * was not nonsense after all * protect tmp ret value from GC, fix readable strong ref deinit/init * fmt * if we detach the stream we cannot update the fetch stream * detach checking source * more tests, progress with javascript and Direct sink * drop support for pure readable stream for now * more fixes --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Diffstat (limited to 'src/http_client_async.zig')
-rw-r--r--src/http_client_async.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index fe9d1e6c1..8a0e6548c 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -1119,6 +1119,8 @@ pub const InternalState = struct {
}
fn decompressConst(this: *InternalState, buffer: []const u8, body_out_str: *MutableString) !void {
+ log("Decompressing {d} bytes\n", .{buffer.len});
+ std.debug.assert(!body_out_str.owns(buffer));
defer this.compressed_body.reset();
var gzip_timer: std.time.Timer = undefined;
@@ -1127,17 +1129,18 @@ pub const InternalState = struct {
var reader: *Zlib.ZlibReaderArrayList = undefined;
if (this.zlib_reader) |current_reader| {
+ std.debug.assert(current_reader.zlib.avail_in == 0);
reader = current_reader;
reader.zlib.next_in = buffer.ptr;
reader.zlib.avail_in = @as(u32, @truncate(buffer.len));
- reader.list = body_out_str.list;
const initial = body_out_str.list.items.len;
body_out_str.list.expandToCapacity();
if (body_out_str.list.capacity == initial) {
try body_out_str.list.ensureUnusedCapacity(body_out_str.allocator, 4096);
body_out_str.list.expandToCapacity();
}
+ reader.list = body_out_str.list;
reader.zlib.next_out = &body_out_str.list.items[initial];
reader.zlib.avail_out = @as(u32, @truncate(body_out_str.list.capacity - initial));
// we reset the total out so we can track how much we decompressed this time