@nxtedition/nxt-undici 4.1.0 → 4.1.2
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/index.js +1 -1
- package/lib/interceptor/cache.js +1 -1
- package/lib/interceptor/dns.js +0 -2
- package/lib/interceptor/log.js +4 -3
- package/lib/interceptor/lookup.js +0 -1
- package/lib/interceptor/redirect.js +5 -5
- package/lib/interceptor/request-body-factory.js +0 -2
- package/lib/interceptor/response-error.js +6 -6
- package/lib/interceptor/response-retry.js +5 -5
- package/lib/interceptor/response-verify.js +6 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -103,7 +103,7 @@ export async function request(url, opts) {
|
|
|
103
103
|
} else if (url instanceof URL) {
|
|
104
104
|
opts = { url, ...opts }
|
|
105
105
|
} else if (typeof url.origin === 'string' && typeof (url.path ?? url.pathname) === 'string') {
|
|
106
|
-
opts = { url, ...opts }
|
|
106
|
+
opts = opts ? { ...url, ...opts } : url
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
if (opts == null && typeof url === 'object' && url != null) {
|
package/lib/interceptor/cache.js
CHANGED
package/lib/interceptor/dns.js
CHANGED
|
@@ -65,7 +65,6 @@ export default (interceptorOpts) => (dispatch) => (opts, handler) => {
|
|
|
65
65
|
|
|
66
66
|
const callback = (err, val) => {
|
|
67
67
|
if (err) {
|
|
68
|
-
handler.onConnect(() => {})
|
|
69
68
|
handler.onError(err)
|
|
70
69
|
} else {
|
|
71
70
|
const url = new URL(opts.origin)
|
|
@@ -88,7 +87,6 @@ export default (interceptorOpts) => (dispatch) => (opts, handler) => {
|
|
|
88
87
|
)
|
|
89
88
|
}
|
|
90
89
|
} catch (err) {
|
|
91
|
-
handler.onConnect(() => {})
|
|
92
90
|
handler.onError(err)
|
|
93
91
|
}
|
|
94
92
|
|
package/lib/interceptor/log.js
CHANGED
|
@@ -3,10 +3,11 @@ import { DecoratorHandler, parseHeaders } from '../utils.js'
|
|
|
3
3
|
class Handler extends DecoratorHandler {
|
|
4
4
|
#handler
|
|
5
5
|
#opts
|
|
6
|
-
#abort
|
|
7
|
-
#aborted = false
|
|
8
6
|
#logger
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
#abort = null
|
|
9
|
+
#aborted = false
|
|
10
|
+
#pos = 0
|
|
10
11
|
#timing = {
|
|
11
12
|
created: performance.now(),
|
|
12
13
|
connect: -1,
|
|
@@ -6,15 +6,15 @@ const redirectableStatusCodes = [300, 301, 302, 303, 307, 308]
|
|
|
6
6
|
class Handler extends DecoratorHandler {
|
|
7
7
|
#dispatch
|
|
8
8
|
#handler
|
|
9
|
-
|
|
10
9
|
#opts
|
|
11
|
-
#abort
|
|
12
|
-
#aborted = false
|
|
13
|
-
#reason
|
|
14
10
|
#maxCount
|
|
11
|
+
|
|
12
|
+
#abort = null
|
|
13
|
+
#aborted = false
|
|
14
|
+
#reason = null
|
|
15
15
|
#headersSent = false
|
|
16
16
|
#count = 0
|
|
17
|
-
#location
|
|
17
|
+
#location = null
|
|
18
18
|
#history = []
|
|
19
19
|
|
|
20
20
|
constructor(opts, { dispatch, handler }) {
|
|
@@ -12,7 +12,6 @@ export default (opts) => (dispatch) => (opts, handler) => {
|
|
|
12
12
|
dispatch({ ...opts, body }, handler)
|
|
13
13
|
})
|
|
14
14
|
.catch((err) => {
|
|
15
|
-
handler.onConnect(() => {})
|
|
16
15
|
handler.onError(err)
|
|
17
16
|
})
|
|
18
17
|
return true
|
|
@@ -20,7 +19,6 @@ export default (opts) => (dispatch) => (opts, handler) => {
|
|
|
20
19
|
return dispatch({ ...opts, body }, handler)
|
|
21
20
|
}
|
|
22
21
|
} catch (err) {
|
|
23
|
-
handler.onConnect(() => {})
|
|
24
22
|
handler.onError(err)
|
|
25
23
|
return true
|
|
26
24
|
}
|
|
@@ -4,12 +4,12 @@ import { DecoratorHandler, parseHeaders } from '../utils.js'
|
|
|
4
4
|
class Handler extends DecoratorHandler {
|
|
5
5
|
#handler
|
|
6
6
|
|
|
7
|
-
#statusCode
|
|
8
|
-
#contentType
|
|
9
|
-
#decoder
|
|
10
|
-
#headers
|
|
11
|
-
#body
|
|
12
|
-
#errored
|
|
7
|
+
#statusCode = 0
|
|
8
|
+
#contentType = null
|
|
9
|
+
#decoder = null
|
|
10
|
+
#headers = null
|
|
11
|
+
#body = ''
|
|
12
|
+
#errored = false
|
|
13
13
|
|
|
14
14
|
constructor(opts, { handler }) {
|
|
15
15
|
super(handler)
|
|
@@ -17,14 +17,14 @@ class Handler extends DecoratorHandler {
|
|
|
17
17
|
#headersSent = false
|
|
18
18
|
#errorSent = false
|
|
19
19
|
|
|
20
|
-
#abort
|
|
20
|
+
#abort = null
|
|
21
21
|
#aborted = false
|
|
22
22
|
#reason = null
|
|
23
23
|
|
|
24
|
-
#pos
|
|
25
|
-
#end
|
|
26
|
-
#etag
|
|
27
|
-
#error
|
|
24
|
+
#pos = null
|
|
25
|
+
#end = null
|
|
26
|
+
#etag = null
|
|
27
|
+
#error = null
|
|
28
28
|
|
|
29
29
|
constructor(opts, { handler, dispatch }) {
|
|
30
30
|
super(handler)
|
|
@@ -8,11 +8,11 @@ class Handler extends DecoratorHandler {
|
|
|
8
8
|
#handler
|
|
9
9
|
|
|
10
10
|
#verifyOpts
|
|
11
|
-
#contentMD5
|
|
12
|
-
#contentLength
|
|
13
|
-
#hasher
|
|
14
|
-
#pos
|
|
15
|
-
#errored
|
|
11
|
+
#contentMD5 = null
|
|
12
|
+
#contentLength = null
|
|
13
|
+
#hasher = null
|
|
14
|
+
#pos = 0
|
|
15
|
+
#errored = false
|
|
16
16
|
|
|
17
17
|
constructor(opts, { handler }) {
|
|
18
18
|
super(handler)
|
|
@@ -74,9 +74,7 @@ class Handler extends DecoratorHandler {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
onError(err) {
|
|
77
|
-
if (this.#errored) {
|
|
78
|
-
// Do nothing...
|
|
79
|
-
} else {
|
|
77
|
+
if (!this.#errored) {
|
|
80
78
|
this.#handler.onError(err)
|
|
81
79
|
}
|
|
82
80
|
}
|