diff options
| author | 8cy <[email protected]> | 2020-04-03 02:48:28 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-04-03 02:48:28 -0700 |
| commit | f9159ea2d994e14180fb02ab562f0119513e67cf (patch) | |
| tree | 09d14cdf05456567156738b681379d4bccd64e5c /node_modules/http-basic/lib/memory-cache.js | |
| parent | 2020/04/03, 02:42, V1.2.1 (diff) | |
| download | s5nical-f9159ea2d994e14180fb02ab562f0119513e67cf.tar.xz s5nical-f9159ea2d994e14180fb02ab562f0119513e67cf.zip | |
2020/04/03, 02:47, V1.2.2
Diffstat (limited to 'node_modules/http-basic/lib/memory-cache.js')
| -rw-r--r-- | node_modules/http-basic/lib/memory-cache.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/node_modules/http-basic/lib/memory-cache.js b/node_modules/http-basic/lib/memory-cache.js deleted file mode 100644 index cf1f5a9..0000000 --- a/node_modules/http-basic/lib/memory-cache.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -var PassThrough = require('stream').PassThrough; -var concat = require('concat-stream'); -var Response = require('http-response-object'); - -module.exports = MemoryCache; -function MemoryCache() { - this._cache = {}; -} - -MemoryCache.prototype.getResponse = function (url, callback) { - var cache = this._cache; - if (cache[url]) { - var body = new PassThrough(); - body.end(cache[url].body); - callback(null, { - statusCode: cache[url].statusCode, - headers: cache[url].headers, - body: body, - requestHeaders: cache[url].requestHeaders, - requestTimestamp: cache[url].requestTimestamp - }); - } else { - callback(null, null); - } -}; -MemoryCache.prototype.setResponse = function (url, response) { - var cache = this._cache; - response.body.pipe(concat(function (body) { - cache[url] = { - statusCode: response.statusCode, - headers: response.headers, - body: body, - requestHeaders: response.requestHeaders, - requestTimestamp: response.requestTimestamp - }; - })); -}; |