aboutsummaryrefslogtreecommitdiff
path: root/src/http.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.zig')
-rw-r--r--src/http.zig37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/http.zig b/src/http.zig
index d2924b804..827bfa6de 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -437,7 +437,7 @@ pub const RequestContext = struct {
.reason = step,
.cwd = this.bundler.fs.top_level_dir,
.problems = Api.Problems{
- .code = @truncate(u16, @errorToInt(err)),
+ .code = @truncate(u16, @intFromError(err)),
.name = @errorName(err),
.exceptions = exceptions,
.build = try log.toAPI(allocator),
@@ -559,7 +559,7 @@ pub const RequestContext = struct {
var stat = file.stat() catch return null;
var absolute_path = resolve_path.joinAbs(this.bundler.options.routes.static_dir, .auto, relative_unrooted_path);
- if (stat.kind == .SymLink) {
+ if (stat.kind == .sym_link) {
file.* = std.fs.openFileAbsolute(absolute_path, .{ .mode = .read_only }) catch return null;
absolute_path = bun.getFdPath(
@@ -570,7 +570,7 @@ pub const RequestContext = struct {
stat = file.stat() catch return null;
}
- if (stat.kind != .File) {
+ if (stat.kind != .file) {
file.close();
return null;
}
@@ -1431,7 +1431,7 @@ pub const RequestContext = struct {
JavaScript.API.Bun.flushCSSImports();
vm.flush();
- Output.printElapsed(@intToFloat(f64, (handler.start_timer.read())) / std.time.ns_per_ms);
+ Output.printElapsed(@floatFromInt(f64, (handler.start_timer.read())) / std.time.ns_per_ms);
if (vm.bundler.options.framework.?.display_name.len > 0) {
Output.prettyError(
@@ -2000,11 +2000,7 @@ pub const RequestContext = struct {
// sometimes the final byte has incorrect data
// we never end up using all those bytes
if (handler.message_buffer.list.items.len > 0) {
- @memset(
- handler.message_buffer.list.items.ptr,
- 0,
- @min(handler.message_buffer.list.items.len, 128),
- );
+ @memset(handler.message_buffer.list.items[0..@min(handler.message_buffer.list.items.len, 128)], 0);
}
const build_result = handler.builder.build(request_id, cmd.timestamp, arena.allocator()) catch |err| {
if (err == error.MissingWatchID) {
@@ -2087,7 +2083,7 @@ pub const RequestContext = struct {
socket_buffers[2] = iovec(build_result.bytes);
// we reuse the accept key buffer
// so we have a pointer that is not stack memory
- handler.accept_key[0..@sizeOf(usize)].* = @bitCast([@sizeOf(usize)]u8, std.hash.Wyhash.hash(0, build_result.bytes));
+ handler.accept_key[0..@sizeOf(usize)].* = @bitCast([@sizeOf(usize)]u8, bun.hash(build_result.bytes));
socket_buffers[3] = iovec(handler.accept_key[0..4]);
socket_buffer_count = 4;
}
@@ -2110,7 +2106,7 @@ pub const RequestContext = struct {
else => {
Output.prettyErrorln(
"<r>[Websocket]: Unknown cmd: <b>{d}<r>. This might be a version mismatch. Try updating your node_modules.bun",
- .{@enumToInt(cmd.kind)},
+ .{@intFromEnum(cmd.kind)},
);
},
}
@@ -2187,7 +2183,7 @@ pub const RequestContext = struct {
};
pub fn writeETag(this: *RequestContext, buffer: anytype) !bool {
- const strong_etag = std.hash.Wyhash.hash(0, buffer);
+ const strong_etag = bun.hash(buffer);
const etag_content_slice = std.fmt.bufPrintIntToSlice(strong_etag_buffer[0..49], strong_etag, 16, .upper, .{});
this.appendHeader("ETag", etag_content_slice);
@@ -2404,7 +2400,7 @@ pub const RequestContext = struct {
// Always cache css & json files, even big ones
// css is especially important because we want to try and skip having the browser parse it whenever we can
if (buf.len < 16 * 16 * 16 * 16 or chunky._loader == .css or chunky._loader == .json) {
- const strong_etag = std.hash.Wyhash.hash(0, buf);
+ const strong_etag = bun.hash(buf);
const etag_content_slice = std.fmt.bufPrintIntToSlice(strong_etag_buffer[0..49], strong_etag, 16, .upper, .{});
chunky.rctx.appendHeader("ETag", etag_content_slice);
@@ -2538,7 +2534,7 @@ pub const RequestContext = struct {
.css => try ctx.sendNoContent(),
.toml, .js, .jsx, .ts, .tsx, .json => {
const buf = "export default {};";
- const strong_etag = comptime std.hash.Wyhash.hash(0, buf);
+ const strong_etag = comptime bun.hash(buf);
const etag_content_slice = std.fmt.bufPrintIntToSlice(strong_etag_buffer[0..49], strong_etag, 16, .upper, .{});
ctx.appendHeader("ETag", etag_content_slice);
@@ -3388,10 +3384,10 @@ pub const Server = struct {
break :brk path_string.slice();
} else {
var file_path_without_trailing_slash = std.mem.trimRight(u8, file_path, std.fs.path.sep_str);
- @memcpy(&_on_file_update_path_buf, file_path_without_trailing_slash.ptr, file_path_without_trailing_slash.len);
+ @memcpy(_on_file_update_path_buf[0..file_path_without_trailing_slash.len], file_path_without_trailing_slash);
_on_file_update_path_buf[file_path_without_trailing_slash.len] = std.fs.path.sep;
- @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len + 1 ..].ptr, changed_name.ptr, changed_name.len);
+ @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len + 1 .. changed_name.len], changed_name);
const path_slice = _on_file_update_path_buf[0 .. file_path_without_trailing_slash.len + changed_name.len + 1];
file_hash = Watcher.getHash(path_slice);
break :brk path_slice;
@@ -3445,12 +3441,9 @@ pub const Server = struct {
.kernel_backlog = 1280,
});
defer listener.deinit();
- server.websocket_threadpool.stack_size = @truncate(
- u32,
- @min(
- @max(128_000, Fs.FileSystem.RealFS.Limit.stack),
- 4_000_000,
- ),
+ server.websocket_threadpool.stack_size = @min(
+ @max(128_000, Fs.FileSystem.RealFS.Limit.stack),
+ 4_000_000,
);
// listener.setFastOpen(true) catch {};