Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Commit

Permalink
fix(cache): refactored warning removal into main file
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 1, 2017
1 parent 5b74cbc commit 5b0a9f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 0 additions & 5 deletions cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ module.exports = class Cache {
put (req, response) {
const size = response.headers.get('content-length')
const fitInMemory = !!size && size < MAX_MEM_SIZE
const warningCode = (response.headers.get('Warning') || '').match(/^\d+/)
if (warningCode && +warningCode >= 100 && +warningCode < 200) {
// https://tools.ietf.org/html/rfc7234#section-4.3.4
response.headers.delete('Warning')
}
const opts = {
metadata: {
url: req.url,
Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ function cachingFetch (uri, _opts) {
headers: opts.headers
})
return opts.cacheManager.match(req, opts.cacheOpts).then(res => {
if (res) {
const warningCode = (res.headers.get('Warning') || '').match(/^\d+/)
if (warningCode && +warningCode >= 100 && +warningCode < 200) {
// https://tools.ietf.org/html/rfc7234#section-4.3.4
res.headers.delete('Warning')
}
}
if (res && opts.cache === 'default' && !isStale(res)) {
return res
} else if (res && (opts.cache === 'default' || opts.cache === 'no-cache')) {
Expand Down

0 comments on commit 5b0a9f9

Please sign in to comment.