@nxtedition/nxt-undici 1.4.1 → 1.4.3
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
CHANGED
|
@@ -127,6 +127,7 @@ class Readable extends stream.Readable {
|
|
|
127
127
|
|
|
128
128
|
const dispatchers = {
|
|
129
129
|
requestBody: require('./interceptor/request-body.js'),
|
|
130
|
+
requestBodyFactory: require('./interceptor/request-body-factory.js'),
|
|
130
131
|
abort: require('./interceptor/abort.js'),
|
|
131
132
|
catch: require('./interceptor/catch.js'),
|
|
132
133
|
responseContent: require('./interceptor/response-content.js'),
|
|
@@ -216,7 +217,7 @@ async function request(url, opts) {
|
|
|
216
217
|
if (dispatch == null) {
|
|
217
218
|
dispatch = (opts, handler) => dispatcher.dispatch(opts, handler)
|
|
218
219
|
dispatch = dispatchers.catch(dispatch)
|
|
219
|
-
dispatch = dispatchers.
|
|
220
|
+
dispatch = dispatchers.requestBodyFactory(dispatch)
|
|
220
221
|
dispatch = dispatchers.abort(dispatch)
|
|
221
222
|
dispatch = dispatchers.requestId(dispatch)
|
|
222
223
|
dispatch = dispatchers.log(dispatch)
|
|
@@ -229,6 +230,7 @@ async function request(url, opts) {
|
|
|
229
230
|
dispatch = dispatchers.signal(dispatch)
|
|
230
231
|
dispatch = dispatchers.cache(dispatch)
|
|
231
232
|
dispatch = dispatchers.proxy(dispatch)
|
|
233
|
+
dispatch = dispatchers.requestBody(dispatch)
|
|
232
234
|
dispatcherCache.set(dispatcher, dispatch)
|
|
233
235
|
}
|
|
234
236
|
|
|
@@ -23,7 +23,7 @@ class Handler {
|
|
|
23
23
|
abort(this.error)
|
|
24
24
|
} else {
|
|
25
25
|
this.abort = abort
|
|
26
|
-
return this.onConnect(abort)
|
|
26
|
+
return this.handler.onConnect(abort)
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -58,22 +58,15 @@ class Handler {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
Promise.resolve(opts.body({ signal: opts.signal })).then(
|
|
64
|
-
(body) => dispatchImpl({ ...opts, body }, handler),
|
|
65
|
-
(err) => handler.onError(err),
|
|
66
|
-
)
|
|
67
|
-
} else if (isStream(opts.body)) {
|
|
61
|
+
module.exports = (dispatch) => (opts, handler) => {
|
|
62
|
+
if (isStream(opts.body)) {
|
|
68
63
|
if (opts.method === 'GET' || opts.method === 'HEAD') {
|
|
69
64
|
opts.body.resume() // dump
|
|
70
|
-
dispatch({ ...opts, body: undefined }, new Handler(opts, { handler }))
|
|
65
|
+
return dispatch({ ...opts, body: undefined }, new Handler(opts, { handler }))
|
|
71
66
|
} else {
|
|
72
|
-
dispatch(opts, new Handler(opts, { handler }))
|
|
67
|
+
return dispatch(opts, new Handler(opts, { handler }))
|
|
73
68
|
}
|
|
74
69
|
} else {
|
|
75
|
-
dispatch(opts, handler)
|
|
70
|
+
return dispatch(opts, handler)
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
|
-
|
|
79
|
-
module.exports = (dispatch) => (opts, handler) => dispatchImpl(dispatch, opts, handler)
|