aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api/server.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-03-18 16:15:21 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-03-18 16:15:21 -0700
commit96fcecdcc9ebae4c81b0238519eaeb4cca2b9881 (patch)
tree8a9adea138bba3e8412ff611185bddc890836501 /src/bun.js/api/server.zig
parent12c4ed89e380fa248f7db115a9df63478a7a3f56 (diff)
downloadbun-96fcecdcc9ebae4c81b0238519eaeb4cca2b9881.tar.gz
bun-96fcecdcc9ebae4c81b0238519eaeb4cca2b9881.tar.zst
bun-96fcecdcc9ebae4c81b0238519eaeb4cca2b9881.zip
[fetch] Make the default body value `null` when unspecified
This is better aligned with the fetch spec
Diffstat (limited to 'src/bun.js/api/server.zig')
-rw-r--r--src/bun.js/api/server.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index d9f59bb07..3cfce400e 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -2252,7 +2252,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
this.has_called_error_handler = true;
var args = [_]JSC.C.JSValueRef{value.asObjectRef()};
const result = JSC.C.JSObjectCallAsFunctionReturnValue(this.server.globalThis, this.server.config.onError.asObjectRef(), this.server.thisObject.asObjectRef(), 1, &args);
-
+ defer result.ensureStillAlive();
if (!result.isEmptyOrUndefinedOrNull()) {
if (result.toError()) |err| {
this.finishRunningErrorHandler(err, status);
@@ -2535,7 +2535,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
if (request.as(Request)) |req| {
var old = req.body;
old.Locked.onReceiveValue = null;
- req.body = .{ .Empty = {} };
+ req.body = .{ .Null = {} };
old.resolve(&req.body, this.server.globalThis);
return;
}
@@ -2546,7 +2546,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
if (request.as(Request)) |req| {
var old = req.body;
old.Locked.onReceiveValue = null;
- req.body = .{ .Empty = {} };
+ req.body = .{ .Null = {} };
old.toError(error.RequestBodyTooLarge, this.server.globalThis);
return;
}
@@ -2563,7 +2563,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
if (request.as(Request)) |req| {
var old = req.body;
old.Locked.onReceiveValue = null;
- req.body = .{ .Empty = {} };
+ req.body = .{ .Null = {} };
old.resolve(&req.body, this.server.globalThis);
return;
}
@@ -4319,7 +4319,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
var url: URL = undefined;
var first_arg = args.nextEat().?;
- var body: JSC.WebCore.Body.Value = .{ .Empty = {} };
+ var body: JSC.WebCore.Body.Value = .{ .Null = {} };
var existing_request: ?WebCore.Request = null;
// TODO: set Host header
// TODO: set User-Agent header
@@ -4738,7 +4738,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
.uws_request = req,
.https = ssl_enabled,
.body = .{
- .Empty = {},
+ .Null = {},
},
};
@@ -4822,7 +4822,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
.upgrader = ctx,
.https = ssl_enabled,
.body = .{
- .Empty = {},
+ .Null = {},
},
};
ctx.upgrade_context = upgrade_ctx;