@nxtedition/nxt-undici 6.0.21 → 6.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/interceptor/cache.js +15 -21
- package/lib/utils.js +4 -4
- package/package.json +1 -1
package/lib/interceptor/cache.js
CHANGED
|
@@ -4,6 +4,7 @@ import { DecoratorHandler, parseCacheControl } from '../utils.js'
|
|
|
4
4
|
const DEFAULT_STORE = new undici.cacheStores.SqliteCacheStore({ location: ':memory:' })
|
|
5
5
|
const MAX_ENTRY_SIZE = 128 * 1024
|
|
6
6
|
const EMPTY_BUFFER = Buffer.alloc(0)
|
|
7
|
+
const NOOP = () => {}
|
|
7
8
|
|
|
8
9
|
class CacheHandler extends DecoratorHandler {
|
|
9
10
|
#key
|
|
@@ -175,27 +176,20 @@ export default () => (dispatch) => (opts, handler) => {
|
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
} else if (state === 4) {
|
|
192
|
-
handler.onComplete({})
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
} catch (err) {
|
|
196
|
-
abort(err)
|
|
197
|
-
}
|
|
179
|
+
handler.onConnect(abort)
|
|
180
|
+
if (aborted) {
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
handler.onHeaders(statusCode, headers, NOOP)
|
|
185
|
+
if (aborted) {
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
handler.onData(body ?? EMPTY_BUFFER)
|
|
190
|
+
if (aborted) {
|
|
191
|
+
return
|
|
198
192
|
}
|
|
199
193
|
|
|
200
|
-
|
|
194
|
+
handler.onComplete({})
|
|
201
195
|
}
|
package/lib/utils.js
CHANGED
|
@@ -276,15 +276,15 @@ export class DecoratorHandler {
|
|
|
276
276
|
})
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
onUpgrade(
|
|
279
|
+
onUpgrade(statusCode, headers, socket) {
|
|
280
280
|
if (!this.#aborted && !this.#errored) {
|
|
281
|
-
return this.#handler.onUpgrade?.(
|
|
281
|
+
return this.#handler.onUpgrade?.(statusCode, headers, socket)
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
onHeaders(
|
|
285
|
+
onHeaders(statusCode, headers, resume) {
|
|
286
286
|
if (!this.#aborted && !this.#errored) {
|
|
287
|
-
return this.#handler.onHeaders?.(
|
|
287
|
+
return this.#handler.onHeaders?.(statusCode, headers, resume)
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|