Skip to content

Commit 7b0c2e8

Browse files
committed
Co-authored-by: Copilot <[email protected]> Copilot-Session: 51629aea-67ec-442e-9b0f-9b0f88b74fea
1 parent e9e99b4 commit 7b0c2e8

3 files changed

Lines changed: 38 additions & 13 deletions

File tree

‎node_modules/http-cache-semantics/index.js‎

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,13 @@ module.exports = class CachePolicy {
334334

335335
/**
336336
* @param {{headers: Record<string, string>, synchronous: boolean}|undefined} revalidation - Revalidation information, if any.
337-
* @returns {{response: {headers: Record<string, string>}, revalidation: {headers: Record<string, string>, synchronous: boolean}|undefined}} An object with a cached response headers and revalidation info.
337+
* @returns {{response: HttpResponse, revalidation: {headers: Record<string, string>, synchronous: boolean}|undefined}} An object with a cached response headers and revalidation info.
338338
*/
339339
_evaluateRequestHitResult(revalidation) {
340340
return {
341341
response: {
342342
headers: this.responseHeaders(),
343+
status: this._status,
343344
},
344345
revalidation,
345346
};
@@ -387,9 +388,9 @@ module.exports = class CachePolicy {
387388
* }
388389
* ```
389390
* @param {HttpRequest} req - new incoming HTTP request
390-
* @returns {{response: {headers: Record<string, string>}|undefined, revalidation: {headers: Record<string, string>, synchronous: boolean}|undefined}} An object containing keys:
391+
* @returns {{response: HttpResponse|undefined, revalidation: {headers: Record<string, string>, synchronous: boolean}|undefined}} An object containing keys:
391392
* - revalidation: { headers: Record<string, string>, synchronous: boolean } Set if you should send this to the origin server
392-
* - response: { headers: Record<string, string> } Set if you can respond to the client with these cached headers
393+
* - response: HttpResponse Set if you can respond to the client with these cached headers
393394
*/
394395
evaluateRequest(req) {
395396
this._assertRequestHasHeaders(req);
@@ -484,18 +485,32 @@ module.exports = class CachePolicy {
484485
return true;
485486
}
486487

487-
// A Vary header field-value of "*" always fails to match
488-
if (this._resHeaders.vary === '*') {
489-
return false;
490-
}
491-
492488
const fields = this._resHeaders.vary
493489
.trim()
494490
.toLowerCase()
495491
.split(/\s*,\s*/);
492+
496493
for (const name of fields) {
497-
if (req.headers[name] !== this._reqHeaders[name]) return false;
494+
// A Vary header field-value of "*" always fails to match
495+
if (name === '*') {
496+
return false;
497+
}
498+
499+
const newReq = Object.prototype.hasOwnProperty.call(
500+
req.headers,
501+
name
502+
) && req.headers[name];
503+
504+
const cachedReq = Object.prototype.hasOwnProperty.call(
505+
this._reqHeaders,
506+
name
507+
) && this._reqHeaders[name];
508+
509+
if (newReq !== cachedReq) {
510+
return false;
511+
}
498512
}
513+
499514
return true;
500515
}
501516

@@ -556,6 +571,14 @@ module.exports = class CachePolicy {
556571
return headers;
557572
}
558573

574+
/**
575+
* Returns the status code of the cached response.
576+
* @returns {number} The response status code.
577+
*/
578+
status() {
579+
return this._status;
580+
}
581+
559582
/**
560583
* Returns the Date header value from the response or the current time if invalid.
561584
* @returns {number} Timestamp (in milliseconds) representing the Date header or response time.

‎node_modules/http-cache-semantics/package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "http-cache-semantics",
3-
"version": "4.2.0",
3+
"version": "4.3.0",
44
"description": "Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies",
55
"repository": {
66
"type": "git",
@@ -14,9 +14,9 @@
1414
"files": [
1515
"index.js"
1616
],
17-
"author": "Kornel Lesiński <npms2@geekhood.net> (https://kornel.ski/)",
17+
"author": "Kornel Lesiński <kornel@geekhood.net> (https://kornel.ski/)",
1818
"license": "BSD-2-Clause",
1919
"devDependencies": {
20-
"mocha": "^11.0"
20+
"mocha": "^12.0"
2121
}
2222
}

‎package-lock.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6537,7 +6537,9 @@
65376537
}
65386538
},
65396539
"node_modules/http-cache-semantics": {
6540-
"version": "4.2.0",
6540+
"version": "4.3.0",
6541+
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.3.0.tgz",
6542+
"integrity": "sha512-M5t5LlJpS1UHMjvwRQVdFHvPISGeLAxNcrWuJkeGh0KxsqCHZ1O3NXZU/8x7cD0BDcGW8kapxMKTvwlqrNkHkA==",
65416543
"inBundle": true,
65426544
"license": "BSD-2-Clause"
65436545
},

0 commit comments

Comments
 (0)