aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/webcore/body.zig12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig
index ad40c56ff..19e92d95a 100644
--- a/src/bun.js/webcore/body.zig
+++ b/src/bun.js/webcore/body.zig
@@ -363,7 +363,10 @@ pub const Body = struct {
JSC.markBinding(@src());
switch (this.*) {
- .Used, .Empty => {
+ .Empty => {
+ return JSValue.jsNull();
+ },
+ .Used => {
return JSC.WebCore.ReadableStream.empty(globalThis);
},
.InternalBlob,
@@ -435,7 +438,7 @@ pub const Body = struct {
pub fn fromJS(
globalThis: *JSGlobalObject,
- value: JSValue,
+ value: JSValue
) ?Value {
value.ensureStillAlive();
@@ -976,6 +979,10 @@ pub fn BodyMixin(comptime Type: type) type {
) callconv(.C) JSValue {
var body: *Body.Value = this.getBodyValue();
+ if (body.* == .Empty) {
+ return JSValue.jsNull();
+ }
+
if (body.* == .Used) {
// TODO: make this closed
return JSC.WebCore.ReadableStream.empty(globalThis);
@@ -997,6 +1004,7 @@ pub fn BodyMixin(comptime Type: type) type {
_: *JSC.CallFrame,
) callconv(.C) JSC.JSValue {
var value: *Body.Value = this.getBodyValue();
+
if (value.* == .Used) {
return handleBodyAlreadyUsed(globalObject);
}