Skip to content

Commit 535f61a

Browse files
committed
allow for generation of weak etags
1 parent 5efafbc commit 535f61a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/util/http.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ const url = (strings, ...parts) => {
119119

120120
// Checks Etag in the request if it matches serverEtag then returns 304
121121
// Otherwise executes given function 'fn'
122-
const withEtag = (serverEtag, fn) => (request, response) => {
122+
const withEtag = (serverEtag, fn, isWeak=false) => (request, response) => {
123123

124-
response.set('ETag', `"${serverEtag}"`);
124+
response.set('ETag', `${isWeak ? 'W/': ''}"${serverEtag}"`);
125125

126126
// Etag logic inspired from https://stackoverflow.com/questions/72334843/custom-computed-etag-for-express-js/72335674#72335674
127127
const clientEtag = request.get('If-None-Match');

0 commit comments

Comments
 (0)