api: use Map for internal stream headers instead of plain object

This commit is contained in:
dumbmoron 2024-07-06 11:36:25 +00:00
parent 315ddb17c1
commit 3096bc9df0
No known key found for this signature in database
2 changed files with 10 additions and 5 deletions

View file

@ -196,10 +196,10 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
return res.sendStatus(404); return res.sendStatus(404);
} }
streamInfo.headers = { streamInfo.headers = new Map([
...streamInfo.headers, streamInfo.headers || {},
...req.headers req.headers
}; ]);
return stream(res, { type: 'internal', ...streamInfo }); return stream(res, { type: 'internal', ...streamInfo });
}) })

View file

@ -87,10 +87,15 @@ export function createInternalStream(url, obj = {}) {
setMaxListeners(Infinity, controller.signal); setMaxListeners(Infinity, controller.signal);
} }
let headers;
if (obj.headers) {
headers = new Map(Object.entries(obj.headers));
}
internalStreamCache[streamID] = { internalStreamCache[streamID] = {
url, url,
service: obj.service, service: obj.service,
headers: obj.headers, headers,
controller, controller,
dispatcher dispatcher
}; };