Socket
Socket
Sign inDemoInstall

http-cache-semantics

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-cache-semantics - npm Package Compare versions

Comparing version 3.7.0 to 3.7.1

test/misctest.js

3

index.js

@@ -470,4 +470,3 @@ 'use strict';

for(const k in this._resHeaders) {
if (excludedFromRevalidationUpdate[k]) continue;
headers[k] = k in response.headers ? response.headers[k] : this._resHeaders[k];
headers[k] = k in response.headers && !excludedFromRevalidationUpdate[k] ? response.headers[k] : this._resHeaders[k];
}

@@ -474,0 +473,0 @@

{
"name": "http-cache-semantics",
"version": "3.7.0",
"version": "3.7.1",
"description": "Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -80,2 +80,26 @@ 'use strict';

it('skips weak validtors on post', function() {
const postReq = simpleRequestBut({method:'POST', headers:{'if-none-match': 'W/"weak", "strong", W/"weak2"'}});
const cache = new CachePolicy(postReq, multiValidatorResponse);
const headers = cache.revalidationHeaders(postReq);
assert.equal(headers['if-none-match'], '"strong", "123456789"');
assert.strictEqual(undefined, headers['if-modified-since']);
});
it('skips weak validtors on post 2', function() {
const postReq = simpleRequestBut({method:'POST', headers:{'if-none-match': 'W/"weak"'}});
const cache = new CachePolicy(postReq, lastModifiedResponse);
const headers = cache.revalidationHeaders(postReq);
assert.strictEqual(undefined, headers['if-none-match']);
assert.strictEqual(undefined, headers['if-modified-since']);
});
it('merges validtors', function() {
const postReq = simpleRequestBut({headers:{'if-none-match': 'W/"weak", "strong", W/"weak2"'}});
const cache = new CachePolicy(postReq, multiValidatorResponse);
const headers = cache.revalidationHeaders(postReq);
assert.equal(headers['if-none-match'], 'W/"weak", "strong", W/"weak2", "123456789"');
assert.equal('Tue, 15 Nov 1994 12:45:26 GMT', headers['if-modified-since']);
});
it('when last-modified validator is present', function() {

@@ -98,3 +122,10 @@ const cache = new CachePolicy(simpleRequest, lastModifiedResponse);

describe('Validation request', function(){
it('removes warnings', function() {
const cache = new CachePolicy({headers:{}}, {headers:{
"warning": "199 test danger",
}});
assert.strictEqual(undefined, cache.responseHeaders().warning);
});
it('must contain any etag', function(){

@@ -107,2 +138,12 @@ const cache = new CachePolicy(simpleRequest,multiValidatorResponse);

it('merges etags', function(){
const cache = new CachePolicy(simpleRequest, etaggedResponse);
const expected = `"foo", "bar", ${etaggedResponse.headers.etag}`;
const headers = cache.revalidationHeaders(simpleRequestBut({headers:{
host:'www.w3c.org',
'if-none-match': '"foo", "bar"',
}}));
assert.equal(headers['if-none-match'],expected);
});
it('should send the Last-Modified value', function(){

@@ -109,0 +150,0 @@ const cache = new CachePolicy(simpleRequest,multiValidatorResponse);

@@ -63,4 +63,7 @@ 'use strict';

it('Last-mod can vary if etag matches', function(){
assertUpdates(simpleRequest, multiValidatorResponse, simpleRequest, multiValidatorResponse);
it('Checks status', function(){
const response304 = Object.assign({}, multiValidatorResponse, {status:304});
const response200 = Object.assign({}, multiValidatorResponse, {status:200});
assertUpdates(simpleRequest, multiValidatorResponse, simpleRequest, response304);
assert(!notModifiedResponseHeaders(simpleRequest, multiValidatorResponse, simpleRequest, response200));
});

@@ -79,2 +82,9 @@

it('Skips update of content-length', function(){
const etaggedResponseWithLenght1 = withHeaders(etaggedResponse, {'content-length':1});
const etaggedResponseWithLenght2 = withHeaders(etaggedResponse, {'content-length':2});
const headers = notModifiedResponseHeaders(simpleRequest, etaggedResponseWithLenght1, simpleRequest, etaggedResponseWithLenght2);
assert.equal(1, headers['content-length']);
});
it('Ignored if validator is different', function(){

@@ -81,0 +91,0 @@ assert(!notModifiedResponseHeaders(simpleRequest, lastModifiedResponse, simpleRequest, etaggedResponse));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with âšĄïž by Socket Inc