Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
function getCacheEntry(url) {
var cacheIndex =_.findIndex(httpCache.cache,function(e){
return e.url === url;
});
if (cacheIndex>=0)
return httpCache.cache[cacheIndex];
else {
var cacheEntry = { url: url };
httpCache.cache.push(cacheEntry);
return cacheEntry;
}
}
converter.ResourceReaders.url = function (url) {
resolverContext.called = true;
var options = {
headers: {
'Accept': 'application/json,*/*',
'Accept-Language': 'en-GB,en;q=0.5'
},
retries : 10
};
var cacheEntry = getCacheEntry(url);
if (cacheEntry && cacheEntry.etag && resolverContext.etag && resolverContext.format !== 'swagger_1') {
options.headers['If-None-Match'] = cacheEntry.etag;
}
return makeRequest('get', url, options)
.then(function(result){
if (result[0].statusCode === 304) {
throw new Error('Warning: 304 Not Modified');