summaryrefslogtreecommitdiff
path: root/node_modules/http-basic/lib/memory-cache.js
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-03 02:48:28 -0700
committer8cy <[email protected]>2020-04-03 02:48:28 -0700
commitf9159ea2d994e14180fb02ab562f0119513e67cf (patch)
tree09d14cdf05456567156738b681379d4bccd64e5c /node_modules/http-basic/lib/memory-cache.js
parent2020/04/03, 02:42, V1.2.1 (diff)
downloads5nical-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.js39
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
- };
- }));
-};