Skip to content

Commit

Permalink
fix: set content-type header (#443)
Browse files Browse the repository at this point in the history
* test: add test for content-type header

* fix: set content-type header

Fixes #442
  • Loading branch information
wkillerud authored Nov 14, 2024
1 parent 8586966 commit 5af702a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/podlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,9 +995,8 @@ export default class PodiumPodlet {
// set "incoming" on res.locals.podium
objobj.set('locals.podium', incoming, res);

if (res.header) {
res.header('podlet-version', this.version);
}
res.header('podlet-version', this.version);
res.header('content-type', 'text/html');

res.sendHeaders = () => {
res.write('');
Expand Down
14 changes: 14 additions & 0 deletions tests/podlet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,20 @@ tap.test(
},
);

tap.test('res.podiumSend() - should set content-type text/html', async (t) => {
const podlet = new Podlet(DEFAULT_OPTIONS);
const server = new FakeExpressServer(podlet, (req, res) => {
res.podiumSend('<h1>OK!</h1>');
});

await server.listen();
const result = await server.get({ raw: true });

t.equal(result.response, '<h1>OK!</h1>');
t.equal(result.headers['content-type'], 'text/html; charset=utf-8');
await server.close();
});

// #############################################
// .defaults()
// #############################################
Expand Down

0 comments on commit 5af702a

Please sign in to comment.