From bfdfcc0eda2c67f24c76457c825511dc5d4b24a5 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Sun, 8 Dec 2024 00:34:36 -0800 Subject: [PATCH] correctly set if-none-match (#3933) --- lib/interceptor/cache.js | 2 +- test/interceptors/cache.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/interceptor/cache.js b/lib/interceptor/cache.js index e3fb202ad21..a60d92617ad 100644 --- a/lib/interceptor/cache.js +++ b/lib/interceptor/cache.js @@ -229,7 +229,7 @@ function handleResult ( } if (result.etag) { - headers.etag = result.etag + headers['if-none-match'] = result.etag } if (result.vary) { diff --git a/test/interceptors/cache.js b/test/interceptors/cache.js index 1b502c212b3..dc120c60b7b 100644 --- a/test/interceptors/cache.js +++ b/test/interceptors/cache.js @@ -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 () => {