@nxtedition/nxt-undici 4.2.24 → 4.2.26
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.
|
@@ -3,23 +3,19 @@ export default (opts) => (dispatch) => (opts, handler) => {
|
|
|
3
3
|
return dispatch(opts, handler)
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const body = opts.body({ signal: opts.signal })
|
|
6
|
+
const body = opts.body({ signal: opts.signal })
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} else {
|
|
19
|
-
return dispatch({ ...opts, body }, handler)
|
|
20
|
-
}
|
|
21
|
-
} catch (err) {
|
|
22
|
-
handler.onError(err)
|
|
8
|
+
if (typeof body?.then === 'function') {
|
|
9
|
+
body.then(
|
|
10
|
+
(body) => {
|
|
11
|
+
dispatch({ ...opts, body }, handler)
|
|
12
|
+
},
|
|
13
|
+
(err) => {
|
|
14
|
+
handler.onError(err)
|
|
15
|
+
},
|
|
16
|
+
)
|
|
23
17
|
return true
|
|
18
|
+
} else {
|
|
19
|
+
return dispatch({ ...opts, body }, handler)
|
|
24
20
|
}
|
|
25
21
|
}
|
|
@@ -17,14 +17,14 @@ class Handler extends DecoratorHandler {
|
|
|
17
17
|
#headersSent = false
|
|
18
18
|
#errorSent = false
|
|
19
19
|
|
|
20
|
-
#abort
|
|
20
|
+
#abort
|
|
21
21
|
#aborted = false
|
|
22
|
-
#reason
|
|
22
|
+
#reason
|
|
23
23
|
|
|
24
|
-
#pos
|
|
25
|
-
#end
|
|
26
|
-
#etag
|
|
27
|
-
#error
|
|
24
|
+
#pos
|
|
25
|
+
#end
|
|
26
|
+
#etag
|
|
27
|
+
#error
|
|
28
28
|
|
|
29
29
|
constructor(opts, { handler, dispatch }) {
|
|
30
30
|
super(handler)
|
|
@@ -87,7 +87,7 @@ class Handler extends DecoratorHandler {
|
|
|
87
87
|
assert(start != null && Number.isFinite(start), 'content-range mismatch')
|
|
88
88
|
assert(end != null && Number.isFinite(end), 'invalid content-length')
|
|
89
89
|
assert(
|
|
90
|
-
contentLength == null || end == null || contentLength === end
|
|
90
|
+
contentLength == null || end == null || contentLength === end - start,
|
|
91
91
|
'content-range mismatch',
|
|
92
92
|
)
|
|
93
93
|
|
|
@@ -168,7 +168,7 @@ class Handler extends DecoratorHandler {
|
|
|
168
168
|
this.#dispatch(this.#opts, this)
|
|
169
169
|
} else {
|
|
170
170
|
assert(Number.isFinite(this.#pos))
|
|
171
|
-
assert(this.#end == null || Number.isFinite(this.#end))
|
|
171
|
+
assert(this.#end == null || (Number.isFinite(this.#end) && this.#end > 0))
|
|
172
172
|
|
|
173
173
|
this.#opts = {
|
|
174
174
|
...this.#opts,
|
|
@@ -177,7 +177,7 @@ class Handler extends DecoratorHandler {
|
|
|
177
177
|
...this.#opts.headers,
|
|
178
178
|
...opts?.headers,
|
|
179
179
|
'if-match': this.#etag,
|
|
180
|
-
range: `bytes=${this.#pos}-${this.#end
|
|
180
|
+
range: `bytes=${this.#pos}-${this.#end ? this.#end - 1 : ''}`,
|
|
181
181
|
},
|
|
182
182
|
}
|
|
183
183
|
|
package/lib/utils.js
CHANGED
|
@@ -10,7 +10,9 @@ export function parseCacheControl(str) {
|
|
|
10
10
|
// Parsed accordingly to RFC 9110
|
|
11
11
|
// https://www.rfc-editor.org/rfc/rfc9110#field.content-range
|
|
12
12
|
export function parseRangeHeader(range) {
|
|
13
|
-
if (range == null || range === '')
|
|
13
|
+
if (range == null || range === '') {
|
|
14
|
+
return { start: 0, end: null, size: null }
|
|
15
|
+
}
|
|
14
16
|
|
|
15
17
|
const m = range ? range.match(/^bytes (\d+)-(\d+)\/(\d+)?$/) : null
|
|
16
18
|
return m
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/nxt-undici",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"cache-control-parser": "^2.0.6",
|
|
13
13
|
"http-errors": "^2.0.0",
|
|
14
|
-
"lru-cache": "^11.0.
|
|
15
|
-
"undici": "^6.
|
|
14
|
+
"lru-cache": "^11.0.2",
|
|
15
|
+
"undici": "^6.20.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@types/node": "^22.
|
|
18
|
+
"@types/node": "^22.9.0",
|
|
19
19
|
"eslint": "^8.0.0",
|
|
20
20
|
"eslint-config-prettier": "^9.1.0",
|
|
21
21
|
"eslint-config-standard": "^17.0.0",
|
|
22
22
|
"eslint-plugin-import": "^2.31.0",
|
|
23
|
-
"eslint-plugin-n": "^17.
|
|
23
|
+
"eslint-plugin-n": "^17.13.1",
|
|
24
24
|
"eslint-plugin-promise": "^7.1.0",
|
|
25
25
|
"husky": "^9.1.6",
|
|
26
26
|
"lint-staged": "^15.2.10",
|