Skip to content

Commit

Permalink
fix(cache): cleanup for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
IsakT committed Jul 11, 2024
1 parent 739a538 commit 83db254
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/interceptor/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,19 @@ class CacheHandler extends DecoratorHandler {

onComplete(rawTrailers) {
if (this.#value) {
// get
const entries = this.#handler.entries
const resHeaders = parseHeaders(this.#value.data.rawHeaders)
const reqHeaders = this.#handler.opts

// set
this.#value.data.rawTrailers = rawTrailers
this.#value.size = this.#value.size
? this.#value.size + rawTrailers?.reduce((xs, x) => xs + x.length, 0)
: 0

const entries = this.#handler.entries

const reqHeaders = this.#handler.opts
const resHeaders = parseHeaders(this.#value.data.rawHeaders)

this.#value.vary = formatVaryData(resHeaders, reqHeaders)

entries.push(this.#value)

sortEntriesByVary(entries)

this.#store.set(this.#key, entries)
}
return this.#handler.onComplete(rawTrailers)
Expand Down

0 comments on commit 83db254

Please sign in to comment.