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-04-13 16:33:11 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-04-13 16:33:11 -0700
commite9016415bc876ed8ad7e173a455ef4b7a96ec51c (patch)
tree8307cbf573a9d04ac3c5a0b6b08b66f757cf47ab /src/bun.js/api/server.zig
parent242aa0be12f6c7fd4d09ed6fd4ce05a6b571b9de (diff)
downloadbun-e9016415bc876ed8ad7e173a455ef4b7a96ec51c.tar.gz
bun-e9016415bc876ed8ad7e173a455ef4b7a96ec51c.tar.zst
bun-e9016415bc876ed8ad7e173a455ef4b7a96ec51c.zip
Only set `is_web_browser_navigation` in debug mode server
Diffstat (limited to 'src/bun.js/api/server.zig')
-rw-r--r--src/bun.js/api/server.zig24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index 61348e19c..1390a4aa8 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -944,8 +944,14 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
request_js_object: JSC.C.JSObjectRef = null,
request_body_buf: std.ArrayListUnmanaged(u8) = .{},
request_body_content_len: usize = 0,
+
+ /// Used to avoid looking at the uws.Request struct after it's been freed
is_transfer_encoding: bool = false,
- is_web_browser_navigation: bool = false,
+
+ /// Used in renderMissing in debug mode to show the user an HTML page
+ /// Used to avoid looking at the uws.Request struct after it's been freed
+ is_web_browser_navigation: if (debug_mode) bool else void = if (debug_mode) false else {},
+
sink: ?*ResponseStream.JSSink = null,
byte_stream: ?*JSC.WebCore.ByteStream = null,
@@ -4951,15 +4957,17 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
},
};
- ctx.is_web_browser_navigation = brk: {
- if (ctx.req.header("sec-fetch-dest")) |fetch_dest| {
- if (strings.eqlComptime(fetch_dest, "document")) {
- break :brk true;
+ if (comptime debug_mode) {
+ ctx.is_web_browser_navigation = brk: {
+ if (ctx.req.header("sec-fetch-dest")) |fetch_dest| {
+ if (strings.eqlComptime(fetch_dest, "document")) {
+ break :brk true;
+ }
}
- }
- break :brk false;
- };
+ break :brk false;
+ };
+ }
// we need to do this very early unfortunately
// it seems to work fine for synchronous requests but anything async will take too long to register the handler