Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-basic

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-basic - npm Package Compare versions

Comparing version 2.5.1 to 3.0.0

test/cache.js

9

index.js

@@ -156,4 +156,9 @@ 'use strict';

return callback(null, res);
} else if (cachedResponse.headers['etag']) {
headers.set('If-None-Match', cachedResponse.headers['etag']);
} else {
if (cachedResponse.headers['etag']) {
headers.set('If-None-Match', cachedResponse.headers['etag']);
}
if (cachedResponse.headers['last-modified']) {
headers.set('If-Modified-Since', cachedResponse.headers['last-modified']);
}
}

@@ -160,0 +165,0 @@ }

@@ -25,2 +25,3 @@ 'use strict';

if (res.headers['etag']) return true;
if (res.headers['last-modified']) return true;
if (/^public\, *max\-age\=(\d+)$/.test(res.headers['cache-control'])) return true;

@@ -27,0 +28,0 @@ if (res.statusCode === 301 || res.statusCode === 308) return true;

{
"name": "http-basic",
"version": "2.5.1",
"version": "3.0.0",
"description": "Very low level wrapper arround http.request/https.request",

@@ -22,5 +22,8 @@ "keywords": [

},
"devDependencies": {},
"devDependencies": {
"rimraf": "^2.5.4",
"serve-static": "^1.11.1"
},
"scripts": {
"test": "node test"
"test": "node test/index && node test/cache"
},

@@ -27,0 +30,0 @@ "repository": {

@@ -39,52 +39,8 @@ 'use strict';

var CACHED = 'https://www.promisejs.org/polyfills/promise-done-1.0.0.js';
request('GET', CACHED, {cache: 'memory'}, function (err, res) {
if (err) throw err;
console.log('response D (populate cache)');
assert(res.statusCode === 200);
res.body.on('data', function () {});
res.body.on('end', function () {
request('GET', CACHED, {cache: 'memory'}, function (err, res) {
if (err) throw err;
console.log('response E (from cache)');
assert(res.fromCache === true);
assert(res.fromNotModified === false);
assert(res.statusCode === 200);
res.body.resume();
});
});
});
request('GET', CACHED, {cache: 'file'}, function (err, res) {
if (err) throw err;
console.log('response G (populate file cache)');
assert(res.statusCode === 200);
res.body.on('data', function () {});
res.body.on('end', function () {
setTimeout(function () {
request('GET', CACHED, {cache: 'file'}, function (err, res) {
if (err) throw err;
console.log('response H (from file cache)');
assert(res.fromCache === true);
assert(res.fromNotModified === false);
assert(res.statusCode === 200);
res.body.resume();
});
}, 1000);
});
});
request('GET', 'https://api.github.com/repos/isaacs/npm', {allowRedirectHeaders: ['User-Agent'], followRedirects: true, headers: {'User-Agent': 'http-basic'}}, function (err, res) {
if (err) throw err;
console.log('response I');
console.log('response D');
assert(res.statusCode === 200);
res.body.resume();
});

Sorry, the diff of this file is not supported yet

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