undici 7.5.0 → 7.6.0
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/docs/docs/api/Agent.md +1 -1
- package/lib/core/util.js +1 -1
- package/lib/handler/cache-revalidation-handler.js +1 -1
- package/lib/interceptor/cache.js +3 -3
- package/lib/mock/mock-utils.js +1 -1
- package/lib/util/cache.js +17 -7
- package/lib/web/fetch/index.js +4 -3
- package/lib/web/websocket/util.js +1 -1
- package/package.json +2 -2
package/docs/docs/api/Agent.md
CHANGED
package/lib/core/util.js
CHANGED
|
@@ -13,7 +13,7 @@ const { InvalidArgumentError } = require('./errors')
|
|
|
13
13
|
const { headerNameLowerCasedRecord } = require('./constants')
|
|
14
14
|
const { tree } = require('./tree')
|
|
15
15
|
|
|
16
|
-
const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(v => Number(v))
|
|
16
|
+
const [nodeMajor, nodeMinor] = process.versions.node.split('.', 2).map(v => Number(v))
|
|
17
17
|
|
|
18
18
|
class BodyAsyncIterable {
|
|
19
19
|
constructor (body) {
|
|
@@ -9,7 +9,7 @@ const assert = require('node:assert')
|
|
|
9
9
|
* here, which we then just pass on to the next handler (most likely a
|
|
10
10
|
* CacheHandler). Note that this assumes the proper headers were already
|
|
11
11
|
* included in the request to tell the origin that we want to revalidate the
|
|
12
|
-
* response (i.e. if-modified-since).
|
|
12
|
+
* response (i.e. if-modified-since or if-none-match).
|
|
13
13
|
*
|
|
14
14
|
* @see https://www.rfc-editor.org/rfc/rfc9111.html#name-validation
|
|
15
15
|
*
|
package/lib/interceptor/cache.js
CHANGED
|
@@ -6,7 +6,7 @@ const util = require('../core/util')
|
|
|
6
6
|
const CacheHandler = require('../handler/cache-handler')
|
|
7
7
|
const MemoryCacheStore = require('../cache/memory-cache-store')
|
|
8
8
|
const CacheRevalidationHandler = require('../handler/cache-revalidation-handler')
|
|
9
|
-
const { assertCacheStore, assertCacheMethods, makeCacheKey, parseCacheControlHeader } = require('../util/cache.js')
|
|
9
|
+
const { assertCacheStore, assertCacheMethods, makeCacheKey, normaliseHeaders, parseCacheControlHeader } = require('../util/cache.js')
|
|
10
10
|
const { AbortError } = require('../core/errors.js')
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -221,7 +221,7 @@ function handleResult (
|
|
|
221
221
|
// Check if the response is stale
|
|
222
222
|
if (needsRevalidation(result, reqCacheControl)) {
|
|
223
223
|
if (util.isStream(opts.body) && util.bodyLength(opts.body) !== 0) {
|
|
224
|
-
// If body is
|
|
224
|
+
// If body is a stream we can't revalidate...
|
|
225
225
|
// TODO (fix): This could be less strict...
|
|
226
226
|
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler))
|
|
227
227
|
}
|
|
@@ -233,7 +233,7 @@ function handleResult (
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
let headers = {
|
|
236
|
-
...opts
|
|
236
|
+
...normaliseHeaders(opts),
|
|
237
237
|
'if-modified-since': new Date(result.cachedAt).toUTCString()
|
|
238
238
|
}
|
|
239
239
|
|
package/lib/mock/mock-utils.js
CHANGED
package/lib/util/cache.js
CHANGED
|
@@ -12,7 +12,21 @@ function makeCacheKey (opts) {
|
|
|
12
12
|
throw new Error('opts.origin is undefined')
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const headers = normaliseHeaders(opts)
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
origin: opts.origin.toString(),
|
|
19
|
+
method: opts.method,
|
|
20
|
+
path: opts.path,
|
|
21
|
+
headers
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {Record<string, string[] | string>}
|
|
27
|
+
* @return {Record<string, string[] | string>}
|
|
28
|
+
*/
|
|
29
|
+
function normaliseHeaders (opts) {
|
|
16
30
|
let headers
|
|
17
31
|
if (opts.headers == null) {
|
|
18
32
|
headers = {}
|
|
@@ -38,12 +52,7 @@ function makeCacheKey (opts) {
|
|
|
38
52
|
throw new Error('opts.headers is not an object')
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
return
|
|
42
|
-
origin: opts.origin.toString(),
|
|
43
|
-
method: opts.method,
|
|
44
|
-
path: opts.path,
|
|
45
|
-
headers
|
|
46
|
-
}
|
|
55
|
+
return headers
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
/**
|
|
@@ -350,6 +359,7 @@ function assertCacheMethods (methods, name = 'CacheMethods') {
|
|
|
350
359
|
|
|
351
360
|
module.exports = {
|
|
352
361
|
makeCacheKey,
|
|
362
|
+
normaliseHeaders,
|
|
353
363
|
assertCacheKey,
|
|
354
364
|
assertCacheValue,
|
|
355
365
|
parseCacheControlHeader,
|
package/lib/web/fetch/index.js
CHANGED
|
@@ -309,7 +309,9 @@ function finalizeAndReportTiming (response, initiatorType = 'other') {
|
|
|
309
309
|
originalURL.href,
|
|
310
310
|
initiatorType,
|
|
311
311
|
globalThis,
|
|
312
|
-
cacheState
|
|
312
|
+
cacheState,
|
|
313
|
+
'', // bodyType
|
|
314
|
+
response.status
|
|
313
315
|
)
|
|
314
316
|
}
|
|
315
317
|
|
|
@@ -994,7 +996,7 @@ function fetchFinale (fetchParams, response) {
|
|
|
994
996
|
// 3. Set fetchParams’s controller’s report timing steps to the following steps given a global object global:
|
|
995
997
|
fetchParams.controller.reportTimingSteps = () => {
|
|
996
998
|
// 1. If fetchParams’s request’s URL’s scheme is not an HTTP(S) scheme, then return.
|
|
997
|
-
if (fetchParams.request.url
|
|
999
|
+
if (!urlIsHttpHttpsScheme(fetchParams.request.url)) {
|
|
998
1000
|
return
|
|
999
1001
|
}
|
|
1000
1002
|
|
|
@@ -1036,7 +1038,6 @@ function fetchFinale (fetchParams, response) {
|
|
|
1036
1038
|
// fetchParams’s request’s URL, fetchParams’s request’s initiator type, global, cacheState, bodyInfo,
|
|
1037
1039
|
// and responseStatus.
|
|
1038
1040
|
if (fetchParams.request.initiatorType != null) {
|
|
1039
|
-
// TODO: update markresourcetiming
|
|
1040
1041
|
markResourceTiming(timingInfo, fetchParams.request.url.href, fetchParams.request.initiatorType, globalThis, cacheState, bodyInfo, responseStatus)
|
|
1041
1042
|
}
|
|
1042
1043
|
}
|
|
@@ -206,7 +206,7 @@ function parseExtensions (extensions) {
|
|
|
206
206
|
|
|
207
207
|
while (position.position < extensions.length) {
|
|
208
208
|
const pair = collectASequenceOfCodePointsFast(';', extensions, position)
|
|
209
|
-
const [name, value = ''] = pair.split('=')
|
|
209
|
+
const [name, value = ''] = pair.split('=', 2)
|
|
210
210
|
|
|
211
211
|
extensionList.set(
|
|
212
212
|
removeHTTPWhitespace(name, true, false),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "undici",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"description": "An HTTP/1.1 client, written from scratch for Node.js",
|
|
5
5
|
"homepage": "https://undici.nodejs.org",
|
|
6
6
|
"bugs": {
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
110
|
"@fastify/busboy": "3.1.1",
|
|
111
|
-
"@matteo.collina/tspl": "^0.
|
|
111
|
+
"@matteo.collina/tspl": "^0.2.0",
|
|
112
112
|
"@sinonjs/fake-timers": "^12.0.0",
|
|
113
113
|
"@types/node": "^18.19.50",
|
|
114
114
|
"abort-controller": "^3.0.0",
|