Skip to content

Commit bfdfcc0

Browse files
authored
correctly set if-none-match (#3933)
1 parent cac18e1 commit bfdfcc0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/interceptor/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function handleResult (
229229
}
230230

231231
if (result.etag) {
232-
headers.etag = result.etag
232+
headers['if-none-match'] = result.etag
233233
}
234234

235235
if (result.vary) {

test/interceptors/cache.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ describe('Cache Interceptor', () => {
155155
}).listen(0)
156156

157157
const client = new Client(`http://localhost:${server.address().port}`)
158+
.compose((dispatch) => {
159+
return (opts, handler) => {
160+
if (opts.headers) {
161+
strictEqual(Object.prototype.hasOwnProperty.call(opts.headers, 'if-none-match'), false)
162+
}
163+
return dispatch(opts, handler)
164+
}
165+
})
158166
.compose(interceptors.cache())
159167

160168
after(async () => {

0 commit comments

Comments
 (0)