aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/webcore
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-06-28 11:46:17 -0400
committerGravatar dave caruso <me@paperdave.net> 2023-06-29 23:40:38 -0400
commitbb697687467b33b47f16d33d2dc8dfcc6ccf7274 (patch)
treeb8bbbdfbbf276d645765ba772399ddde4f1f3700 /src/bun.js/webcore
parent9e2e3732127ea77803e87cc8768c9040d1717ca7 (diff)
downloadbun-bb697687467b33b47f16d33d2dc8dfcc6ccf7274.tar.gz
bun-bb697687467b33b47f16d33d2dc8dfcc6ccf7274.tar.zst
bun-bb697687467b33b47f16d33d2dc8dfcc6ccf7274.zip
stuff
Diffstat (limited to 'src/bun.js/webcore')
-rw-r--r--src/bun.js/webcore/response.zig35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index b4ea08579..0dce5bfa3 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -222,6 +222,14 @@ pub const Response = struct {
if (content_type.len > 0) {
this.body.init.headers.?.put("content-type", content_type, globalThis);
}
+ } else if (this.body.value == .Locked) {
+ // EventStream defines "contentType"
+ const locked = this.body.value.Locked;
+ if (locked.readable) |readable| {
+ if (readable.value.getOptional(locked.global, "contentType", ZigString.Slice) catch null) |slice| {
+ this.body.init.headers.?.put("content-type", slice.slice(), globalThis);
+ }
+ }
}
}
@@ -536,12 +544,22 @@ pub const Response = struct {
.url = "",
};
- if (response.body.value == .Blob and
- response.body.init.headers != null and
- response.body.value.Blob.content_type.len > 0 and
- !response.body.init.headers.?.fastHas(.ContentType))
- {
- response.body.init.headers.?.put("content-type", response.body.value.Blob.content_type, globalThis);
+ if (response.body.init.headers != null) {
+ if (response.body.value == .Blob and
+ response.body.value.Blob.content_type.len > 0 and
+ !response.body.init.headers.?.fastHas(.ContentType))
+ {
+ response.body.init.headers.?.put("content-type", response.body.value.Blob.content_type, globalThis);
+ } else if (response.body.value == .Locked) {
+ const locked = response.body.value.Locked;
+ if (locked.readable) |readable| {
+ if (readable.value.fastGetDirect(locked.global, .contentType) catch null) |value| {
+ if (value.isString()) {
+ response.body.init.headers.?.put("content-type", value.toBunString(locked.global).toSlice(), globalThis);
+ }
+ }
+ }
+ }
}
return response;
@@ -1725,14 +1743,11 @@ pub const FetchEvent = struct {
if (strings.eqlComptime(name, "content-length")) {
content_length = std.fmt.parseInt(usize, headers.asStr(header.value), 10) catch null;
- continue;
}
// Some headers need to be managed by bun
if (strings.eqlComptime(name, "transfer-encoding") or
- strings.eqlComptime(name, "content-encoding") or
- strings.eqlComptime(name, "strict-transport-security") or
- strings.eqlComptime(name, "content-security-policy"))
+ strings.eqlComptime(name, "content-encoding"))
{
continue;
}