Skip to content

Commit 72cc2bd

Browse files
authored
Merge pull request #173 from fastify/fix_172
2 parents ef33c53 + 9887902 commit 72cc2bd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ function setVaryHeader (reply) {
403403
if (reply.hasHeader('Vary')) {
404404
const varyHeader = Array.isArray(reply.getHeader('Vary')) ? reply.getHeader('Vary') : [reply.getHeader('Vary')]
405405
if (!varyHeader.some((h) => h.includes('accept-encoding'))) {
406-
reply.header('Vary', [...varyHeader, 'accept-encoding'])
406+
reply.header('Vary', `${varyHeader.join(', ')}, accept-encoding`)
407407
}
408408
} else {
409409
reply.header('Vary', 'accept-encoding')

test/test-global-compress.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ test('should concat accept-encoding to vary header if present', t => {
18291829
}
18301830
}, (err, res) => {
18311831
t.error(err)
1832-
t.same(res.headers.vary, ['different-header', 'accept-encoding'])
1832+
t.same(res.headers.vary, 'different-header, accept-encoding')
18331833
})
18341834

18351835
fastify.inject({
@@ -1840,7 +1840,7 @@ test('should concat accept-encoding to vary header if present', t => {
18401840
}
18411841
}, (err, res) => {
18421842
t.error(err)
1843-
t.same(res.headers.vary, ['different-header', 'my-header', 'accept-encoding'])
1843+
t.same(res.headers.vary, 'different-header, my-header, accept-encoding')
18441844
})
18451845
})
18461846

@@ -1856,7 +1856,7 @@ test('should not add accept-encoding to vary header if already present', t => {
18561856
})
18571857

18581858
fastify.get('/foo', (req, reply) => {
1859-
reply.header('vary', ['accept-encoding', 'different-header', 'my-header'])
1859+
reply.header('vary', 'accept-encoding, different-header, my-header')
18601860
reply.type('text/plain').compress(createReadStream('./package.json'))
18611861
})
18621862

@@ -1879,6 +1879,6 @@ test('should not add accept-encoding to vary header if already present', t => {
18791879
}
18801880
}, (err, res) => {
18811881
t.error(err)
1882-
t.same(res.headers.vary, ['accept-encoding', 'different-header', 'my-header'])
1882+
t.same(res.headers.vary, 'accept-encoding, different-header, my-header')
18831883
})
18841884
})

0 commit comments

Comments
 (0)