Skip to content

Commit

Permalink
feat: Set Vary header.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh authored and joachimvh committed Jan 21, 2021
1 parent b487dc7 commit 693d48b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/presets/middleware.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
{
"@type": "HeaderHandler",
"HeaderHandler:_headers": [
{
"HeaderHandler:_headers_key": "Vary",
"HeaderHandler:_headers_value": "Accept,Authorization,Origin"
},
{
"HeaderHandler:_headers_key": "X-Powered-By",
"HeaderHandler:_headers_value": "Community Solid Server"
Expand Down
21 changes: 21 additions & 0 deletions test/integration/Middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ describe('An Express server with middleware', (): void => {
server.close();
});

it('sets a Vary header containing Accept.', async(): Promise<void> => {
const res = await request(server).get('/');
expect(res.header).toEqual(expect.objectContaining({
vary: expect.stringMatching(/(^|,)\s*Accept\s*(,|$)/iu),
}));
});

it('sets a Vary header containing Authorization.', async(): Promise<void> => {
const res = await request(server).get('/');
expect(res.header).toEqual(expect.objectContaining({
vary: expect.stringMatching(/(^|,)\s*Authorization\s*(,|$)/iu),
}));
});

it('sets a Vary header containing Origin.', async(): Promise<void> => {
const res = await request(server).get('/');
expect(res.header).toEqual(expect.objectContaining({
vary: expect.stringMatching(/(^|,)\s*Origin\s*(,|$)/iu),
}));
});

it('sends server identification in the X-Powered-By header.', async(): Promise<void> => {
const res = await request(server).get('/');
expect(res.header).toEqual(expect.objectContaining({
Expand Down

0 comments on commit 693d48b

Please sign in to comment.