aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api/server.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/api/server.zig')
-rw-r--r--src/bun.js/api/server.zig8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index acd870c08..0f967785e 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -2372,6 +2372,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn doRenderWithBody(this: *RequestContext, value: *JSC.WebCore.Body.Value) void {
+ // If a ReadableStream can trivially be converted to a Blob, do so.
+ // If it's a WTFStringImpl and it cannot be used as a UTF-8 string, convert it to a Blob.
value.toBlobIfPossible();
switch (value.*) {
@@ -2386,10 +2388,12 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
return;
},
// .InlineBlob,
+ .WTFStringImpl,
.InternalBlob,
.Blob,
=> {
- this.blob = value.useAsAnyBlob();
+ // toBlobIfPossible checks for WTFString needing a conversion.
+ this.blob = value.useAsAnyBlobAllowNonUTF8String();
this.renderWithBlobFromBodyValue();
return;
},
@@ -2528,7 +2532,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
// Faster to do the memcpy than to do the two network calls
// We are not streaming
// This is an important performance optimization
- if (this.has_abort_handler and this.blob.size() < 16384 - 1024) {
+ if (this.has_abort_handler and this.blob.fastSize() < 16384 - 1024) {
if (this.resp) |resp| {
resp.runCorkedWithType(*RequestContext, doRenderBlobCorked, this);
}