Skip to content

Commit

Permalink
correctly set if-none-match (#3933)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina authored Dec 8, 2024
1 parent cac18e1 commit bfdfcc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/interceptor/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function handleResult (
}

if (result.etag) {
headers.etag = result.etag
headers['if-none-match'] = result.etag
}

if (result.vary) {
Expand Down
8 changes: 8 additions & 0 deletions test/interceptors/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ describe('Cache Interceptor', () => {
}).listen(0)

const client = new Client(`http://localhost:${server.address().port}`)
.compose((dispatch) => {
return (opts, handler) => {
if (opts.headers) {
strictEqual(Object.prototype.hasOwnProperty.call(opts.headers, 'if-none-match'), false)
}
return dispatch(opts, handler)
}
})
.compose(interceptors.cache())

after(async () => {
Expand Down

0 comments on commit bfdfcc0

Please sign in to comment.