stream/types: attempt to pass through headers only if they exist

This commit is contained in:
dumbmoron 2024-04-27 10:47:09 +00:00
parent 66e58d21ec
commit 5f1dc89c42
No known key found for this signature in database

View file

@ -88,8 +88,11 @@ export async function streamDefault(streamInfo, res) {
maxRedirections: 16
});
res.setHeader('content-type', headers['content-type']);
res.setHeader('content-length', headers['content-length']);
for (const headerName of ['content-type', 'content-length']) {
if (headers[headerName]) {
res.setHeader(headerName, headers[headerName]);
}
}
pipe(stream, res, shutdown);
} catch {