aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-08 01:18:36 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-08 01:18:36 -0700
commit38df5b146fab5e8b7d8d52e81ce1d385c3590f3d (patch)
treeab64e0548c483ab89ecf59c6a04d7d45b29b0b28 /src/bun.js/bindings/webcore/JSFetchHeaders.cpp
parent25c91aecab8aae72f030843abfcdeee2595fc9d1 (diff)
downloadbun-38df5b146fab5e8b7d8d52e81ce1d385c3590f3d.tar.gz
bun-38df5b146fab5e8b7d8d52e81ce1d385c3590f3d.tar.zst
bun-38df5b146fab5e8b7d8d52e81ce1d385c3590f3d.zip
Enable `Headers.prototype.getSetCookie`
Fixes #4057
Diffstat (limited to 'src/bun.js/bindings/webcore/JSFetchHeaders.cpp')
-rw-r--r--src/bun.js/bindings/webcore/JSFetchHeaders.cpp33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/bun.js/bindings/webcore/JSFetchHeaders.cpp b/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
index c604ea112..08b5d8ee6 100644
--- a/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
+++ b/src/bun.js/bindings/webcore/JSFetchHeaders.cpp
@@ -258,28 +258,15 @@ JSC_DEFINE_HOST_FUNCTION(jsFetchHeadersPrototypeFunction_getSetCookie, (JSGlobal
return JSValue::encode(JSC::constructEmptyArray(lexicalGlobalObject, nullptr, 0));
}
- JSC::JSArray* array = nullptr;
- GCDeferralContext deferralContext(lexicalGlobalObject->vm());
- JSC::ObjectInitializationScope initializationScope(lexicalGlobalObject->vm());
- if ((array = JSC::JSArray::tryCreateUninitializedRestricted(
- initializationScope, &deferralContext,
- lexicalGlobalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous),
- count))) {
- for (unsigned i = 0; i < count; ++i) {
- array->initializeIndex(initializationScope, i, jsString(vm, values[i]));
- RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined()));
- }
- } else {
- array = constructEmptyArray(lexicalGlobalObject, nullptr, count);
- RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined()));
- if (!array) {
- throwOutOfMemoryError(lexicalGlobalObject, scope);
- return JSValue::encode(jsUndefined());
- }
- for (unsigned i = 0; i < count; ++i) {
- array->putDirectIndex(lexicalGlobalObject, i, jsString(vm, values[i]));
- RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined()));
- }
+ JSC::JSArray* array = constructEmptyArray(lexicalGlobalObject, nullptr, count);
+ RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined()));
+ if (UNLIKELY(!array)) {
+ throwOutOfMemoryError(lexicalGlobalObject, scope);
+ return JSValue::encode(jsUndefined());
+ }
+
+ for (unsigned i = 0; i < count; ++i) {
+ array->putDirectIndex(lexicalGlobalObject, i, jsString(vm, values[i]));
RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined()));
}
@@ -302,7 +289,7 @@ static const HashTableValue JSFetchHeadersPrototypeTableValues[] = {
{ "forEach"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_forEach, 1 } },
{ "toJSON"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_toJSON, 0 } },
{ "count"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, jsFetchHeadersGetterCount, 0 } },
- // { "getSetCookie"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_getSetCookie, 0 } },
+ { "getSetCookie"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsFetchHeadersPrototypeFunction_getSetCookie, 0 } },
};
const ClassInfo JSFetchHeadersPrototype::s_info = { "Headers"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchHeadersPrototype) };