http-basic
Advanced tools
Comparing version 2.5.1 to 3.0.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27261
12
591
2
6