From 3096bc9df03e6f493de27f679a34b3e1343b3992 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sat, 6 Jul 2024 11:36:25 +0000 Subject: [PATCH] api: use Map for internal stream headers instead of plain object --- src/core/api.js | 8 ++++---- src/modules/stream/manage.js | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/api.js b/src/core/api.js index a366ad09..cf5b51a5 100644 --- a/src/core/api.js +++ b/src/core/api.js @@ -196,10 +196,10 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) { return res.sendStatus(404); } - streamInfo.headers = { - ...streamInfo.headers, - ...req.headers - }; + streamInfo.headers = new Map([ + streamInfo.headers || {}, + req.headers + ]); return stream(res, { type: 'internal', ...streamInfo }); }) diff --git a/src/modules/stream/manage.js b/src/modules/stream/manage.js index 06c73a6b..af041a67 100644 --- a/src/modules/stream/manage.js +++ b/src/modules/stream/manage.js @@ -87,10 +87,15 @@ export function createInternalStream(url, obj = {}) { setMaxListeners(Infinity, controller.signal); } + let headers; + if (obj.headers) { + headers = new Map(Object.entries(obj.headers)); + } + internalStreamCache[streamID] = { url, service: obj.service, - headers: obj.headers, + headers, controller, dispatcher };