aboutsummaryrefslogtreecommitdiff
path: root/src/javascript/jsc/api
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-03-23 04:26:49 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-03-23 04:26:49 -0700
commit07d77c1e00a3c74774ab4ea8c79d5bdeb0d9be4a (patch)
tree52b4a5c69ac1f0a5433166a92004a3134ba935f2 /src/javascript/jsc/api
parent5e5f0bd2930a0e1a2f897ba6e857be05e8ca04f2 (diff)
downloadbun-07d77c1e00a3c74774ab4ea8c79d5bdeb0d9be4a.tar.gz
bun-07d77c1e00a3c74774ab4ea8c79d5bdeb0d9be4a.tar.zst
bun-07d77c1e00a3c74774ab4ea8c79d5bdeb0d9be4a.zip
[bun.js] Bun.write for macOS
Diffstat (limited to 'src/javascript/jsc/api')
-rw-r--r--src/javascript/jsc/api/html_rewriter.zig18
-rw-r--r--src/javascript/jsc/api/server.zig8
2 files changed, 9 insertions, 17 deletions
diff --git a/src/javascript/jsc/api/html_rewriter.zig b/src/javascript/jsc/api/html_rewriter.zig
index a85a62ac8..a9f5f5d48 100644
--- a/src/javascript/jsc/api/html_rewriter.zig
+++ b/src/javascript/jsc/api/html_rewriter.zig
@@ -303,7 +303,7 @@ pub const HTMLRewriter = struct {
const is_pending = input.needsToReadFile();
defer if (!is_pending) input.detach();
- if (input.needsToReadFile()) {
+ if (is_pending) {
input.doReadFileInternal(*BufferOutputSink, sink, onFinishedLoadingWrap, global);
} else if (sink.runOutputSink(input.sharedView(), false)) |error_value| {
return error_value;
@@ -321,8 +321,6 @@ pub const HTMLRewriter = struct {
}
pub fn onFinishedLoading(sink: *BufferOutputSink, bytes: anyerror![]u8) void {
- var input = sink.input;
- defer input.detach();
const data = bytes catch |err| {
if (sink.response.body.value == .Locked and @ptrToInt(sink.response.body.value.Locked.task) == @ptrToInt(sink)) {
sink.response.body.value = .{ .Empty = .{} };
@@ -378,16 +376,10 @@ pub const HTMLRewriter = struct {
this.response.body.value = .{
.Blob = JSC.WebCore.Blob.init(bytes, this.bytes.allocator, this.global),
};
-
- if (prev_value.Locked.promise) |promise| {
- prev_value.Locked.promise = null;
- promise.asInternalPromise().?.resolve(this.global, JSC.JSValue.fromRef(
- Response.makeMaybePooled(
- this.global.ref(),
- this.response,
- ),
- ));
- }
+ prev_value.resolve(
+ &this.response.body.value,
+ this.global,
+ );
}
pub fn write(this: *BufferOutputSink, bytes: []const u8) void {
diff --git a/src/javascript/jsc/api/server.zig b/src/javascript/jsc/api/server.zig
index cd769c616..1360f4d52 100644
--- a/src/javascript/jsc/api/server.zig
+++ b/src/javascript/jsc/api/server.zig
@@ -298,7 +298,7 @@ pub fn NewServer(comptime ssl_enabled: bool) type {
}
} else {
var sbytes: std.os.off_t = adjusted_count;
- const signed_offset = @bitCast(i64, this.sendfile.offset);
+ const signed_offset = @bitCast(i64, @as(u64, this.sendfile.offset));
// var sf_hdr_trailer: std.os.darwin.sf_hdtr = .{
// .headers = &separator_iovec,
@@ -320,9 +320,9 @@ pub fn NewServer(comptime ssl_enabled: bool) type {
null,
0,
));
-
- this.sendfile.offset += sbytes;
- this.sendfile.remain -= @intCast(JSC.WebCore.Blob.SizeType, sbytes);
+ const wrote = @intCast(Blob.SizeType, sbytes);
+ this.sendfile.offset += wrote;
+ this.sendfile.remain -= wrote;
if (errcode != .AGAIN or this.aborted or this.sendfile.remain == 0 or sbytes == 0) {
if (errcode != .AGAIN and errcode != .SUCCESS) {
Output.prettyErrorln("Error: {s}", .{@tagName(errcode)});