@wiajs/req 1.7.23 → 1.7.25
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/node/req.cjs +13 -9
- package/dist/req.js +1 -1
- package/dist/req.min.js +1 -1
- package/dist/web/req.cjs +1 -1
- package/dist/web/req.mjs +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/lib/adapters/http.js +10 -6
- package/package.json +2 -2
package/dist/node/req.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @wia/req v1.7.
|
|
2
|
+
* @wia/req v1.7.25
|
|
3
3
|
* (c) 2024 Sibyl Yu, Matt Zabriskie and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -2917,8 +2917,14 @@ class HttpAdapter {
|
|
|
2917
2917
|
|
|
2918
2918
|
if (config.httpAgent) options.agents = {http: config.httpAgent};
|
|
2919
2919
|
if (config.httpsAgent) options.agents.https = config.httpAgent;
|
|
2920
|
-
|
|
2921
|
-
|
|
2920
|
+
|
|
2921
|
+
// ! 配置了 agent,使用Agent,否则使用缺省 agent,agents 优于agent
|
|
2922
|
+
if (config.agents) options.agents = config.agents;
|
|
2923
|
+
else if (config.agent) options.agents = new agent.Agent(config.agent);
|
|
2924
|
+
|
|
2925
|
+
const isHttpsRequest = isHttps.test(options.protocol);
|
|
2926
|
+
// agents 优先于 agent,在 request中根据协议从 agents 中获取
|
|
2927
|
+
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
2922
2928
|
|
|
2923
2929
|
// cacheable-lookup integration hotfix
|
|
2924
2930
|
if (!utils$1.isUndefined(lookup)) options.lookup = lookup;
|
|
@@ -2933,11 +2939,6 @@ class HttpAdapter {
|
|
|
2933
2939
|
|
|
2934
2940
|
// 执行请求的具体对象
|
|
2935
2941
|
_.transport = config.transport;
|
|
2936
|
-
|
|
2937
|
-
const isHttpsRequest = isHttps.test(options.protocol);
|
|
2938
|
-
// agents 优先于 agent,在 request中根据协议从 agents 中获取
|
|
2939
|
-
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
2940
|
-
|
|
2941
2942
|
if (config.maxBodyLength > -1) options.maxBodyLength = config.maxBodyLength;
|
|
2942
2943
|
// follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
|
|
2943
2944
|
else options.maxBodyLength = Number.POSITIVE_INFINITY;
|
|
@@ -2947,7 +2948,10 @@ class HttpAdapter {
|
|
|
2947
2948
|
// 自动跳转
|
|
2948
2949
|
// else {
|
|
2949
2950
|
// 支持跳转或stream,需使用 http、https 封装类
|
|
2950
|
-
|
|
2951
|
+
|
|
2952
|
+
options.maxRedirects = config.maxRedirects ?? 21;
|
|
2953
|
+
options.followRedirects = config.followRedirects ?? true; // 默认自动跳转
|
|
2954
|
+
if (config.maxRedirects === 0) options.followRedirects = false;
|
|
2951
2955
|
if (config.beforeRedirect) options.beforeRedirects.config = config.beforeRedirect;
|
|
2952
2956
|
|
|
2953
2957
|
if (config.insecureHTTPParser) options.insecureHTTPParser = config.insecureHTTPParser;
|
package/dist/req.js
CHANGED
package/dist/req.min.js
CHANGED
package/dist/web/req.cjs
CHANGED
package/dist/web/req.mjs
CHANGED
package/index.d.cts
CHANGED
|
@@ -497,6 +497,7 @@ declare namespace axios {
|
|
|
497
497
|
validateStatus?: ((status: number) => boolean) | null
|
|
498
498
|
maxBodyLength?: number
|
|
499
499
|
maxRedirects?: number
|
|
500
|
+
followRedirects?: boolean
|
|
500
501
|
maxRate?: number | [MaxUploadRate, MaxDownloadRate]
|
|
501
502
|
beforeRedirect?: (
|
|
502
503
|
options: Record<string, any>,
|
package/index.d.ts
CHANGED
|
@@ -391,6 +391,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
|
391
391
|
validateStatus?: ((status: number) => boolean) | null
|
|
392
392
|
maxBodyLength?: number
|
|
393
393
|
maxRedirects?: number
|
|
394
|
+
followRedirects?: boolean
|
|
394
395
|
maxRate?: number | [MaxUploadRate, MaxDownloadRate]
|
|
395
396
|
beforeRedirect?: (
|
|
396
397
|
options: Record<string, any>,
|
package/lib/adapters/http.js
CHANGED
|
@@ -272,8 +272,12 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
|
|
|
272
272
|
http: config.httpAgent
|
|
273
273
|
};
|
|
274
274
|
if (config.httpsAgent) options.agents.https = config.httpAgent;
|
|
275
|
-
// ! 配置了 agent,使用Agent,否则使用缺省 agent
|
|
276
|
-
if (config.
|
|
275
|
+
// ! 配置了 agent,使用Agent,否则使用缺省 agent,agents 优于agent
|
|
276
|
+
if (config.agents) options.agents = config.agents;
|
|
277
|
+
else if (config.agent) options.agents = new Agent(config.agent);
|
|
278
|
+
const isHttpsRequest = isHttps.test(options.protocol);
|
|
279
|
+
// agents 优先于 agent,在 request中根据协议从 agents 中获取
|
|
280
|
+
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
277
281
|
// cacheable-lookup integration hotfix
|
|
278
282
|
if (!utils.isUndefined(lookup)) options.lookup = lookup;
|
|
279
283
|
if (config.socketPath) options.socketPath = config.socketPath;
|
|
@@ -283,9 +287,6 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
|
|
|
283
287
|
}
|
|
284
288
|
// 执行请求的具体对象
|
|
285
289
|
_.transport = config.transport;
|
|
286
|
-
const isHttpsRequest = isHttps.test(options.protocol);
|
|
287
|
-
// agents 优先于 agent,在 request中根据协议从 agents 中获取
|
|
288
|
-
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
289
290
|
if (config.maxBodyLength > -1) options.maxBodyLength = config.maxBodyLength;
|
|
290
291
|
else options.maxBodyLength = Number.POSITIVE_INFINITY;
|
|
291
292
|
// maxRedirects 缺省 21,不跳转,直接使用系统http or https,不支持 stream
|
|
@@ -293,7 +294,10 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
|
|
|
293
294
|
// 自动跳转
|
|
294
295
|
// else {
|
|
295
296
|
// 支持跳转或stream,需使用 http、https 封装类
|
|
296
|
-
|
|
297
|
+
options.maxRedirects = config.maxRedirects ?? 21;
|
|
298
|
+
options.followRedirects = config.followRedirects ?? true // 默认自动跳转
|
|
299
|
+
;
|
|
300
|
+
if (config.maxRedirects === 0) options.followRedirects = false;
|
|
297
301
|
if (config.beforeRedirect) options.beforeRedirects.config = config.beforeRedirect;
|
|
298
302
|
if (config.insecureHTTPParser) options.insecureHTTPParser = config.insecureHTTPParser;
|
|
299
303
|
// _.data = data
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wiajs/req",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.25",
|
|
4
4
|
"description": "Promise And Stream based AXIOS client for the browser and node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
},
|
|
144
144
|
"dependencies": {
|
|
145
145
|
"@wiajs/log": "^4.3.19",
|
|
146
|
-
"@wiajs/request": "^3.0.
|
|
146
|
+
"@wiajs/request": "^3.0.31",
|
|
147
147
|
"@wiajs/agent": "^1.0.21",
|
|
148
148
|
"form-data": "^4.0.0",
|
|
149
149
|
"proxy-from-env": "^1.1.0"
|