@wiajs/request 3.0.27 → 3.0.29
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/dist/request.cjs +24 -15
- package/dist/request.mjs +24 -15
- package/lib/index.js +24 -15
- package/package.json +1 -1
package/dist/request.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia request v3.0.
|
|
2
|
+
* wia request v3.0.29
|
|
3
3
|
* (c) 2022-2024 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -1596,37 +1596,46 @@ utils.createErrorType(
|
|
|
1596
1596
|
|
|
1597
1597
|
/**
|
|
1598
1598
|
* 初始化参数
|
|
1599
|
-
* @param {*} uri
|
|
1600
|
-
* @param {*}
|
|
1601
|
-
* @param {*}
|
|
1599
|
+
* @param {*} uri/opts
|
|
1600
|
+
* @param {*} opts/cb
|
|
1601
|
+
* @param {*} cb/null
|
|
1602
1602
|
* @returns
|
|
1603
1603
|
*/
|
|
1604
|
-
function init(uri,
|
|
1604
|
+
function init(uri, opts, cb) {
|
|
1605
1605
|
let R;
|
|
1606
1606
|
try {
|
|
1607
1607
|
// Parse parameters, ensuring that input is an object
|
|
1608
1608
|
if (utils.isURL(uri)) uri = utils.spreadUrlObject(uri);
|
|
1609
1609
|
else if (utils.isString(uri)) uri = utils.spreadUrlObject(utils.parseUrl(uri));
|
|
1610
1610
|
else {
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1611
|
+
cb = opts;
|
|
1612
|
+
opts = uri;
|
|
1613
|
+
const {url} = opts;
|
|
1614
|
+
if (url) {
|
|
1615
|
+
delete opts.url;
|
|
1616
|
+
if (utils.isURL(url)) uri = utils.spreadUrlObject(url);
|
|
1617
|
+
else if (utils.isString(url)) uri = utils.spreadUrlObject(utils.parseUrl(url));
|
|
1618
|
+
} else {
|
|
1619
|
+
opts = utils.validateUrl(uri);
|
|
1620
|
+
uri = {};
|
|
1621
|
+
}
|
|
1614
1622
|
}
|
|
1615
1623
|
|
|
1616
|
-
if (utils.isFunction(
|
|
1617
|
-
|
|
1618
|
-
|
|
1624
|
+
if (utils.isFunction(opts)) {
|
|
1625
|
+
cb = opts;
|
|
1626
|
+
opts = null;
|
|
1619
1627
|
}
|
|
1620
1628
|
|
|
1621
1629
|
// copy options
|
|
1622
|
-
|
|
1630
|
+
opts = {
|
|
1623
1631
|
...uri,
|
|
1624
|
-
...
|
|
1632
|
+
...opts,
|
|
1625
1633
|
};
|
|
1626
1634
|
|
|
1627
|
-
if (!utils.isString(
|
|
1635
|
+
if (!utils.isString(opts.host) && !utils.isString(opts.hostname)) opts.hostname = '::1';
|
|
1636
|
+
if (opts.method) opts.method = opts.method.toUpperCase();
|
|
1628
1637
|
|
|
1629
|
-
R = {opts:
|
|
1638
|
+
R = {opts: opts, cb: cb};
|
|
1630
1639
|
// log({R}, 'init')
|
|
1631
1640
|
} catch (e) {
|
|
1632
1641
|
log.err(e, 'init');
|
package/dist/request.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia request v3.0.
|
|
2
|
+
* wia request v3.0.29
|
|
3
3
|
* (c) 2022-2024 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -1593,37 +1593,46 @@ utils.createErrorType(
|
|
|
1593
1593
|
|
|
1594
1594
|
/**
|
|
1595
1595
|
* 初始化参数
|
|
1596
|
-
* @param {*} uri
|
|
1597
|
-
* @param {*}
|
|
1598
|
-
* @param {*}
|
|
1596
|
+
* @param {*} uri/opts
|
|
1597
|
+
* @param {*} opts/cb
|
|
1598
|
+
* @param {*} cb/null
|
|
1599
1599
|
* @returns
|
|
1600
1600
|
*/
|
|
1601
|
-
function init(uri,
|
|
1601
|
+
function init(uri, opts, cb) {
|
|
1602
1602
|
let R;
|
|
1603
1603
|
try {
|
|
1604
1604
|
// Parse parameters, ensuring that input is an object
|
|
1605
1605
|
if (utils.isURL(uri)) uri = utils.spreadUrlObject(uri);
|
|
1606
1606
|
else if (utils.isString(uri)) uri = utils.spreadUrlObject(utils.parseUrl(uri));
|
|
1607
1607
|
else {
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1608
|
+
cb = opts;
|
|
1609
|
+
opts = uri;
|
|
1610
|
+
const {url} = opts;
|
|
1611
|
+
if (url) {
|
|
1612
|
+
delete opts.url;
|
|
1613
|
+
if (utils.isURL(url)) uri = utils.spreadUrlObject(url);
|
|
1614
|
+
else if (utils.isString(url)) uri = utils.spreadUrlObject(utils.parseUrl(url));
|
|
1615
|
+
} else {
|
|
1616
|
+
opts = utils.validateUrl(uri);
|
|
1617
|
+
uri = {};
|
|
1618
|
+
}
|
|
1611
1619
|
}
|
|
1612
1620
|
|
|
1613
|
-
if (utils.isFunction(
|
|
1614
|
-
|
|
1615
|
-
|
|
1621
|
+
if (utils.isFunction(opts)) {
|
|
1622
|
+
cb = opts;
|
|
1623
|
+
opts = null;
|
|
1616
1624
|
}
|
|
1617
1625
|
|
|
1618
1626
|
// copy options
|
|
1619
|
-
|
|
1627
|
+
opts = {
|
|
1620
1628
|
...uri,
|
|
1621
|
-
...
|
|
1629
|
+
...opts,
|
|
1622
1630
|
};
|
|
1623
1631
|
|
|
1624
|
-
if (!utils.isString(
|
|
1632
|
+
if (!utils.isString(opts.host) && !utils.isString(opts.hostname)) opts.hostname = '::1';
|
|
1633
|
+
if (opts.method) opts.method = opts.method.toUpperCase();
|
|
1625
1634
|
|
|
1626
|
-
R = {opts:
|
|
1635
|
+
R = {opts: opts, cb: cb};
|
|
1627
1636
|
// log({R}, 'init')
|
|
1628
1637
|
} catch (e) {
|
|
1629
1638
|
log.err(e, 'init');
|
package/lib/index.js
CHANGED
|
@@ -25,34 +25,43 @@ const WritebBeenAbortedError = utils.createErrorType('ERR_STREAM_WRITE_BEEN_ABOR
|
|
|
25
25
|
* 支持隧道及非隧道、http(s)代理
|
|
26
26
|
*/ /**
|
|
27
27
|
* 初始化参数
|
|
28
|
-
* @param {*} uri
|
|
29
|
-
* @param {*}
|
|
30
|
-
* @param {*}
|
|
28
|
+
* @param {*} uri/opts
|
|
29
|
+
* @param {*} opts/cb
|
|
30
|
+
* @param {*} cb/null
|
|
31
31
|
* @returns
|
|
32
|
-
*/ function init(uri,
|
|
32
|
+
*/ function init(uri, opts, cb) {
|
|
33
33
|
let R;
|
|
34
34
|
try {
|
|
35
35
|
// Parse parameters, ensuring that input is an object
|
|
36
36
|
if (utils.isURL(uri)) uri = utils.spreadUrlObject(uri);
|
|
37
37
|
else if (utils.isString(uri)) uri = utils.spreadUrlObject(utils.parseUrl(uri));
|
|
38
38
|
else {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
cb = opts;
|
|
40
|
+
opts = uri;
|
|
41
|
+
const { url } = opts;
|
|
42
|
+
if (url) {
|
|
43
|
+
delete opts.url;
|
|
44
|
+
if (utils.isURL(url)) uri = utils.spreadUrlObject(url);
|
|
45
|
+
else if (utils.isString(url)) uri = utils.spreadUrlObject(utils.parseUrl(url));
|
|
46
|
+
} else {
|
|
47
|
+
opts = utils.validateUrl(uri);
|
|
48
|
+
uri = {};
|
|
49
|
+
}
|
|
42
50
|
}
|
|
43
|
-
if (utils.isFunction(
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
if (utils.isFunction(opts)) {
|
|
52
|
+
cb = opts;
|
|
53
|
+
opts = null;
|
|
46
54
|
}
|
|
47
55
|
// copy options
|
|
48
|
-
|
|
56
|
+
opts = {
|
|
49
57
|
...uri,
|
|
50
|
-
...
|
|
58
|
+
...opts
|
|
51
59
|
};
|
|
52
|
-
if (!utils.isString(
|
|
60
|
+
if (!utils.isString(opts.host) && !utils.isString(opts.hostname)) opts.hostname = '::1';
|
|
61
|
+
if (opts.method) opts.method = opts.method.toUpperCase();
|
|
53
62
|
R = {
|
|
54
|
-
opts:
|
|
55
|
-
cb:
|
|
63
|
+
opts: opts,
|
|
64
|
+
cb: cb
|
|
56
65
|
};
|
|
57
66
|
// log({R}, 'init')
|
|
58
67
|
} catch (e) {
|
package/package.json
CHANGED