While calling for the first time to an api, it showing network error but still it saving in cache. For next time it fetching from cache and working. Dynamic injected code in file
-> node_modules\tree-gateway\dist\pipeline\cache\server-cache.js
ServerCache.cacheStore.get(req.originalUrl, function(err, entry){
if (err) {
return next();
}
if (entry) {
res.contentType(entry.mimeType || "text/html");
res.send(new Buffer(entry.content, "base64"));
}
else {
req.parseRespBody = true;
var send = res.send.bind(res);
res.send = function (body) {
var ret = send(body);
if ( !body ) {
body = '';
}
body = new Buffer(body).toString("base64");
if ( typeof body !== "string" ) {
return ret;
}
if ((res.statusCode >= 200 && res.statusCode < 300) || (res.statusCode === 304)){
ServerCache.cacheStore.set(req.originalUrl, {content: body,mimeType: this._headers["content-type"]}, 10000);
}
return ret;
};
return next();
}
});
return;
While calling for the first time to an api, it showing network error but still it saving in cache. For next time it fetching from cache and working. Dynamic injected code in file
-> node_modules\tree-gateway\dist\pipeline\cache\server-cache.js
ServerCache.cacheStore.get(req.originalUrl, function(err, entry){
if (err) {
return next();
});
return;