Skip to content

Commit

Permalink
Don't set response headers if they're not present
Browse files Browse the repository at this point in the history
  • Loading branch information
tadzik committed Sep 5, 2024
1 parent afdfd30 commit b2ce852
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/media-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,15 @@ export class MediaProxy {
},
}, (getRes) => {
const { statusCode } = res;
res.setHeader('content-disposition', getRes.headers['content-disposition'] as string);
res.setHeader('content-type', getRes.headers['content-type'] as string);
res.setHeader('content-length', getRes.headers['content-length'] as string);
if (getRes.headers['content-disposition']) {
res.setHeader('content-disposition', getRes.headers['content-disposition']);
}
if (getRes.headers['content-type']) {
res.setHeader('content-type', getRes.headers['content-type']);
}
if (getRes.headers['content-length']) {
res.setHeader('content-length', getRes.headers['content-length']);
}
res.status(statusCode);
getRes.pipe(res);
});
Expand Down

0 comments on commit b2ce852

Please sign in to comment.