diff options
author | 2021-09-05 02:05:45 -0700 | |
---|---|---|
committer | 2021-09-05 02:05:45 -0700 | |
commit | c20df72d7319ff55ed4e5c9c7ff1abaab951d0bd (patch) | |
tree | c4e9489eb072f08af62ad58ee57cf04e436f6ef7 /src/http.zig | |
parent | b8941666b46f9b7aa46e3f3db42b429a0d1d26cd (diff) | |
download | bun-c20df72d7319ff55ed4e5c9c7ff1abaab951d0bd.tar.gz bun-c20df72d7319ff55ed4e5c9c7ff1abaab951d0bd.tar.zst bun-c20df72d7319ff55ed4e5c9c7ff1abaab951d0bd.zip |
more mutexes
Former-commit-id: 52966012b4b74d24ab28a0c75740aef35fb75327
Diffstat (limited to 'src/http.zig')
-rw-r--r-- | src/http.zig | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/http.zig b/src/http.zig index e013c7dbf..7270ca09f 100644 --- a/src/http.zig +++ b/src/http.zig @@ -1823,6 +1823,30 @@ pub const RequestContext = struct { } } } + + if (written.empty) { + switch (loader) { + .css => try ctx.sendNoContent(), + .js, .jsx, .ts, .tsx, .json => { + const buf = "export default {};"; + const strong_etag = comptime std.hash.Wyhash.hash(1, buf); + const etag_content_slice = std.fmt.bufPrintIntToSlice(strong_etag_buffer[0..49], strong_etag, 16, .upper, .{}); + ctx.appendHeader("ETag", etag_content_slice); + + if (ctx.header("If-None-Match")) |etag_header| { + if (std.mem.eql(u8, etag_content_slice, etag_header.value)) { + try ctx.sendNotModified(); + return; + } + } + defer ctx.done(); + try ctx.writeStatus(200); + try ctx.prepareToSendBody(buf.len, false); + try ctx.writeBodyBuf(buf); + }, + else => unreachable, + } + } }, .noop => { try ctx.sendNotFound(); @@ -2045,7 +2069,7 @@ pub const RequestContext = struct { ctx.url.pathWithoutAssetPrefix(ctx.bundler.options.routes.asset_prefix_path), ctx.url.extname, false, - true, + false, ); } } |