diff options
author | 2023-04-28 17:40:44 -0300 | |
---|---|---|
committer | 2023-04-28 13:40:44 -0700 | |
commit | 4515a6373e22246e2ec6df4475dc63a965bf9c4a (patch) | |
tree | b7a3dd436ecbbef454468ed71a7583ee590e16f7 /src/bun.js/webcore/blob.zig | |
parent | c383638ddd0b220c482e2e0ec7baa2f650d05776 (diff) | |
download | bun-4515a6373e22246e2ec6df4475dc63a965bf9c4a.tar.gz bun-4515a6373e22246e2ec6df4475dc63a965bf9c4a.tar.zst bun-4515a6373e22246e2ec6df4475dc63a965bf9c4a.zip |
Improves Body.Value life cycle and Signal life cycle on server.zig (#2752)
* reestruct request body value and signal
* revert react-hello-world
* fix constructInto and test
* fmt
* fix body nullable
* Request can outlive RequestContext
* fmt
* BodyValue is now HiveRef
* hasDecl for Ref and HiveRef
* fix deinit call on Ref/HiveRef
* adds InlineBlob
* fix Bun.inspect when using InlineBlob
* revert InlineBlob
* Fix mimalloc-debug
* Add TODO note
* fix: make node:crypto Hash.copy work correctly (#2761)
This commit will also:
- add a CryptoHasher.copy function
- make CryptoHasher.digest reset the hasher so it can be reused
Resolves #2651
* :nail_care:
* address unicode issue (#2763)
* Fix an oopsie
* Another oopsie
* use inline for
* Fixup
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Request can outlive RequestContext
* fmt
* garantee to have the abort signnal attached to the server before abort the client on bun-server test
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Silver <14016168+silversquirl@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Diffstat (limited to 'src/bun.js/webcore/blob.zig')
-rw-r--r-- | src/bun.js/webcore/blob.zig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index c5e07b13c..5723a36b4 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -711,7 +711,7 @@ pub const Blob = struct { } if (data.as(Request)) |request| { - switch (request.body) { + switch (request.body.value) { // .InlineBlob, .InternalBlob, .Used, @@ -719,13 +719,13 @@ pub const Blob = struct { .Blob, .Null, => { - break :brk request.body.use(); + break :brk request.body.value.use(); }, .Error => { destination_blob.detach(); - const err = request.body.Error; + const err = request.body.value.Error; JSC.C.JSValueUnprotect(ctx, err.asObjectRef()); - _ = request.body.use(); + _ = request.body.value.use(); return JSC.JSPromise.rejectedPromiseValue(ctx.ptr(), err).asObjectRef(); }, .Locked => { @@ -737,8 +737,8 @@ pub const Blob = struct { .promise = promise, }; - request.body.Locked.task = task; - request.body.Locked.onReceiveValue = WriteFileWaitFromLockedValueTask.thenWrap; + request.body.value.Locked.task = task; + request.body.value.Locked.onReceiveValue = WriteFileWaitFromLockedValueTask.thenWrap; return promise.asValue(ctx.ptr()).asObjectRef(); }, @@ -3436,6 +3436,9 @@ pub const AnyBlob = union(enum) { switch (this.*) { .Blob => return this.Blob.toString(global, lifetime), // .InlineBlob => { + // if (this.InlineBlob.len == 0) { + // return ZigString.Empty.toValue(global); + // } // const owned = this.InlineBlob.toStringOwned(global); // this.* = .{ .InlineBlob = .{ .len = 0 } }; // return owned; @@ -3457,7 +3460,7 @@ pub const AnyBlob = union(enum) { .Blob => return this.Blob.toArrayBuffer(global, lifetime), // .InlineBlob => { // if (this.InlineBlob.len == 0) { - // return JSC.ArrayBuffer.empty.toJS(global, null); + // return JSC.ArrayBuffer.create(global, "", .ArrayBuffer); // } // var bytes = this.InlineBlob.sliceConst(); // this.InlineBlob.len = 0; |