aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/webcore/response.zig57
1 files changed, 30 insertions, 27 deletions
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index 8fc282cf0..da1655821 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -792,6 +792,36 @@ pub const Fetch = struct {
return;
}
+ if (this.readable_stream_ref.get()) |readable| {
+ if (readable.ptr == .Bytes) {
+ readable.ptr.Bytes.size_hint = this.getSizeHint();
+ // body can be marked as used but we still need to pipe the data
+ var scheduled_response_buffer = this.scheduled_response_buffer.list;
+
+ const chunk = scheduled_response_buffer.items;
+
+ if (this.result.has_more) {
+ readable.ptr.Bytes.onData(
+ .{
+ .temporary = bun.ByteList.initConst(chunk),
+ },
+ bun.default_allocator,
+ );
+
+ // clean for reuse later
+ this.scheduled_response_buffer.reset();
+ } else {
+ readable.ptr.Bytes.onData(
+ .{
+ .temporary_and_done = bun.ByteList.initConst(chunk),
+ },
+ bun.default_allocator,
+ );
+ }
+ return;
+ }
+ }
+
if (this.response.get()) |response_js| {
if (response_js.as(Response)) |response| {
const body = response.body;
@@ -854,33 +884,6 @@ pub const Fetch = struct {
old.resolve(&response.body.value, this.global_this);
}
}
- } else if (this.readable_stream_ref.get()) |readable| {
- if (readable.ptr == .Bytes) {
- readable.ptr.Bytes.size_hint = this.getSizeHint();
- // body can be marked as used but we still need to pipe the data
- var scheduled_response_buffer = this.scheduled_response_buffer.list;
-
- const chunk = scheduled_response_buffer.items;
-
- if (this.result.has_more) {
- readable.ptr.Bytes.onData(
- .{
- .temporary = bun.ByteList.initConst(chunk),
- },
- bun.default_allocator,
- );
-
- // clean for reuse later
- this.scheduled_response_buffer.reset();
- } else {
- readable.ptr.Bytes.onData(
- .{
- .temporary_and_done = bun.ByteList.initConst(chunk),
- },
- bun.default_allocator,
- );
- }
- }
}
}
}