@zwa73/utils 1.0.173 → 1.0.174
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/UtilCom.d.ts +17 -17
- package/dist/UtilCom.js +33 -33
- package/package.json +1 -1
- package/src/UtilCom.ts +36 -36
package/dist/UtilCom.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type ComRequestOption = {
|
|
|
20
20
|
'Content-Type'?: 'application/json' | AnyString;
|
|
21
21
|
/**内容长度 一般无需填写 应为buffer长度而非字符串长度 */
|
|
22
22
|
'Content-Length'?: number;
|
|
23
|
-
}
|
|
23
|
+
} & Record<string, string | number | boolean>;
|
|
24
24
|
};
|
|
25
25
|
type HttpResp = {
|
|
26
26
|
/**响应头 */
|
|
@@ -34,35 +34,35 @@ type HttpResp = {
|
|
|
34
34
|
export declare namespace UtilCom {
|
|
35
35
|
/**发送一个 https POST 请求并接受数据
|
|
36
36
|
* @async
|
|
37
|
-
* @param
|
|
37
|
+
* @param reqData - 数据对象
|
|
38
38
|
* @param comReqOpt - 请求参数
|
|
39
39
|
* @returns 结果 undefined 为未能成功接收
|
|
40
40
|
*/
|
|
41
|
-
function httpsPost(
|
|
41
|
+
function httpsPost(reqData: JObject | undefined, comReqOpt: Omit<ComRequestOption, 'protocol' | 'method'>): Promise<HttpResp | undefined>;
|
|
42
42
|
/**发送一个 http POST 请求并接受数据
|
|
43
43
|
* @async
|
|
44
|
-
* @param
|
|
44
|
+
* @param reqData - 数据对象
|
|
45
45
|
* @param comReqOpt - 请求参数
|
|
46
46
|
* @returns 结果 undefined 为未能成功接收
|
|
47
47
|
*/
|
|
48
|
-
function httpPost(
|
|
48
|
+
function httpPost(reqData: JObject | undefined, comReqOpt: Omit<ComRequestOption, 'protocol' | 'method'>): Promise<HttpResp | undefined>;
|
|
49
49
|
/**发送一个 https GET 请求并接受数据
|
|
50
50
|
* @async
|
|
51
|
-
* @param
|
|
51
|
+
* @param reqData - 数据对象
|
|
52
52
|
* @param comReqOpt - 请求参数
|
|
53
53
|
* @returns 结果 undefined 为未能成功接收
|
|
54
54
|
*/
|
|
55
|
-
function httpsGet(
|
|
55
|
+
function httpsGet(reqData: JObject | undefined, comReqOpt: Omit<ComRequestOption, 'protocol' | 'method'>): Promise<HttpResp | undefined>;
|
|
56
56
|
/**发送一个 http GET 请求并接受数据
|
|
57
57
|
* @async
|
|
58
|
-
* @param
|
|
58
|
+
* @param reqData - 数据对象
|
|
59
59
|
* @param comReqOpt - 请求参数
|
|
60
60
|
* @returns 结果 undefined 为未能成功接收
|
|
61
61
|
*/
|
|
62
|
-
function httpGet(
|
|
62
|
+
function httpGet(reqData: JObject | undefined, comReqOpt: Omit<ComRequestOption, 'protocol' | 'method'>): Promise<HttpResp | undefined>;
|
|
63
63
|
/**重复一个 https POST请求并接受数据
|
|
64
64
|
* @async
|
|
65
|
-
* @param
|
|
65
|
+
* @param reqData - 数据对象
|
|
66
66
|
* @param comReqOpt - 请求参数
|
|
67
67
|
* @param verifyFn - 判断有效性函数
|
|
68
68
|
* @param repeatOpt - 可选参数
|
|
@@ -71,10 +71,10 @@ export declare namespace UtilCom {
|
|
|
71
71
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
72
72
|
* @returns 结果 undefined 为未能成功接收
|
|
73
73
|
*/
|
|
74
|
-
function httpsRepeatPost(
|
|
74
|
+
function httpsRepeatPost(reqData: JObject | undefined, comReqOpt: Omit<ComRequestOption, 'protocol' | 'method'>, verifyFn?: ReqVerifyFn<JObject | undefined>, repeatOpt?: RepeatPromiseOpt): Promise<RepeatPromiseResult<HttpResp | undefined> | undefined>;
|
|
75
75
|
/**重复一个 http POST请求并接受数据
|
|
76
76
|
* @async
|
|
77
|
-
* @param
|
|
77
|
+
* @param reqData - 数据对象
|
|
78
78
|
* @param comReqOpt - 请求参数
|
|
79
79
|
* @param verifyFn - 判断有效性函数
|
|
80
80
|
* @param repeatOpt - 可选参数
|
|
@@ -83,10 +83,10 @@ export declare namespace UtilCom {
|
|
|
83
83
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
84
84
|
* @returns 结果 undefined 为未能成功接收
|
|
85
85
|
*/
|
|
86
|
-
function httpRepeatPost(
|
|
86
|
+
function httpRepeatPost(reqData: JObject | undefined, comReqOpt: Omit<ComRequestOption, 'protocol' | 'method'>, verifyFn?: ReqVerifyFn<JObject | undefined>, repeatOpt?: RepeatPromiseOpt): Promise<RepeatPromiseResult<HttpResp | undefined> | undefined>;
|
|
87
87
|
/**重复一个 https GET 请求并接受数据
|
|
88
88
|
* @async
|
|
89
|
-
* @param
|
|
89
|
+
* @param reqData - 数据对象
|
|
90
90
|
* @param comReqOpt - 请求参数
|
|
91
91
|
* @param verifyFn - 判断有效性函数
|
|
92
92
|
* @param repeatOpt - 可选参数
|
|
@@ -95,10 +95,10 @@ export declare namespace UtilCom {
|
|
|
95
95
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
96
96
|
* @returns 结果 undefined 为未能成功接收
|
|
97
97
|
*/
|
|
98
|
-
function httpsRepeatGet(
|
|
98
|
+
function httpsRepeatGet(reqData: JObject | undefined, comReqOpt: Omit<ComRequestOption, 'protocol' | 'method'>, verifyFn?: ReqVerifyFn<JObject | undefined>, repeatOpt?: RepeatPromiseOpt): Promise<RepeatPromiseResult<HttpResp | undefined> | undefined>;
|
|
99
99
|
/**重复一个 http GET 请求并接受数据
|
|
100
100
|
* @async
|
|
101
|
-
* @param
|
|
101
|
+
* @param reqData - 数据对象
|
|
102
102
|
* @param comReqOpt - 请求参数
|
|
103
103
|
* @param verifyFn - 判断有效性函数
|
|
104
104
|
* @param repeatOpt - 可选参数
|
|
@@ -107,6 +107,6 @@ export declare namespace UtilCom {
|
|
|
107
107
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
108
108
|
* @returns 结果 undefined 为未能成功接收
|
|
109
109
|
*/
|
|
110
|
-
function httpRepeatGet(
|
|
110
|
+
function httpRepeatGet(reqData: JObject | undefined, comReqOpt: Omit<ComRequestOption, 'protocol' | 'method'>, verifyFn?: ReqVerifyFn<JObject | undefined>, repeatOpt?: RepeatPromiseOpt): Promise<RepeatPromiseResult<HttpResp | undefined> | undefined>;
|
|
111
111
|
}
|
|
112
112
|
export {};
|
package/dist/UtilCom.js
CHANGED
|
@@ -13,12 +13,12 @@ const querystring_1 = __importDefault(require("querystring"));
|
|
|
13
13
|
var UtilCom;
|
|
14
14
|
(function (UtilCom) {
|
|
15
15
|
/**通用post处理
|
|
16
|
-
* @param
|
|
16
|
+
* @param reqData - 数据对象
|
|
17
17
|
* @param comReqOpt - 请求参数
|
|
18
18
|
* @param timeLimit - 超时时间/秒 最小为10秒
|
|
19
19
|
* @returns 结果 undefined 为未能成功接收
|
|
20
20
|
*/
|
|
21
|
-
function comReq(
|
|
21
|
+
function comReq(reqData, comReqOpt) {
|
|
22
22
|
let { protocol, timeLimit, ...baseOpt } = comReqOpt;
|
|
23
23
|
//转换为毫秒
|
|
24
24
|
const hasTimeLimit = (timeLimit ? timeLimit >= 10 : false);
|
|
@@ -27,10 +27,10 @@ var UtilCom;
|
|
|
27
27
|
const fixlimit = timeLimit;
|
|
28
28
|
const isPost = baseOpt.method == "POST";
|
|
29
29
|
const isHttps = protocol == "https";
|
|
30
|
-
const jsonStr = isPost ? UtilFunctions_1.UtilFunc.stringifyJToken(
|
|
30
|
+
const jsonStr = isPost ? reqData != undefined ? UtilFunctions_1.UtilFunc.stringifyJToken(reqData) : '' : '';
|
|
31
31
|
const funcName = `${protocol}${baseOpt.method}`;
|
|
32
|
-
if (!isPost)
|
|
33
|
-
baseOpt.path += `?${querystring_1.default.stringify(
|
|
32
|
+
if (!isPost && reqData != undefined)
|
|
33
|
+
baseOpt.path += `?${querystring_1.default.stringify(reqData)}`;
|
|
34
34
|
return new Promise((resolve, rejecte) => {
|
|
35
35
|
const resFunc = (res) => {
|
|
36
36
|
try {
|
|
@@ -95,14 +95,14 @@ var UtilCom;
|
|
|
95
95
|
UtilLogger_1.SLogger.warn(`${funcName} 发送请求错误:${e}`);
|
|
96
96
|
resolve(undefined);
|
|
97
97
|
});
|
|
98
|
-
if (
|
|
98
|
+
if (isPost && reqData != undefined)
|
|
99
99
|
req.write(jsonStr);
|
|
100
100
|
req.end();
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
/**通用重复post处理
|
|
104
104
|
* @async
|
|
105
|
-
* @param
|
|
105
|
+
* @param reqData - 数据对象
|
|
106
106
|
* @param comReqOpt - 请求参数
|
|
107
107
|
* @param verifyFn - 判断有效性函数
|
|
108
108
|
* @param repeatOpt - 可选参数
|
|
@@ -111,19 +111,19 @@ var UtilCom;
|
|
|
111
111
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
112
112
|
* @returns 结果 undefined 为未能成功接收
|
|
113
113
|
*/
|
|
114
|
-
async function repeatComReq(
|
|
114
|
+
async function repeatComReq(reqData, comReqOpt, verifyFn, repeatOpt = {}) {
|
|
115
115
|
repeatOpt.tryDelay = repeatOpt.tryDelay ?? 1;
|
|
116
|
-
const procFn = () => comReq(
|
|
116
|
+
const procFn = () => comReq(reqData, comReqOpt);
|
|
117
117
|
return UtilFunctions_1.UtilFunc.repeatPromise(procFn, verifyFn, repeatOpt);
|
|
118
118
|
}
|
|
119
119
|
/**发送一个 https POST 请求并接受数据
|
|
120
120
|
* @async
|
|
121
|
-
* @param
|
|
121
|
+
* @param reqData - 数据对象
|
|
122
122
|
* @param comReqOpt - 请求参数
|
|
123
123
|
* @returns 结果 undefined 为未能成功接收
|
|
124
124
|
*/
|
|
125
|
-
function httpsPost(
|
|
126
|
-
return comReq(
|
|
125
|
+
function httpsPost(reqData, comReqOpt) {
|
|
126
|
+
return comReq(reqData, {
|
|
127
127
|
...comReqOpt,
|
|
128
128
|
method: "POST",
|
|
129
129
|
protocol: "https",
|
|
@@ -132,12 +132,12 @@ var UtilCom;
|
|
|
132
132
|
UtilCom.httpsPost = httpsPost;
|
|
133
133
|
/**发送一个 http POST 请求并接受数据
|
|
134
134
|
* @async
|
|
135
|
-
* @param
|
|
135
|
+
* @param reqData - 数据对象
|
|
136
136
|
* @param comReqOpt - 请求参数
|
|
137
137
|
* @returns 结果 undefined 为未能成功接收
|
|
138
138
|
*/
|
|
139
|
-
function httpPost(
|
|
140
|
-
return comReq(
|
|
139
|
+
function httpPost(reqData, comReqOpt) {
|
|
140
|
+
return comReq(reqData, {
|
|
141
141
|
...comReqOpt,
|
|
142
142
|
method: "POST",
|
|
143
143
|
protocol: "http",
|
|
@@ -146,12 +146,12 @@ var UtilCom;
|
|
|
146
146
|
UtilCom.httpPost = httpPost;
|
|
147
147
|
/**发送一个 https GET 请求并接受数据
|
|
148
148
|
* @async
|
|
149
|
-
* @param
|
|
149
|
+
* @param reqData - 数据对象
|
|
150
150
|
* @param comReqOpt - 请求参数
|
|
151
151
|
* @returns 结果 undefined 为未能成功接收
|
|
152
152
|
*/
|
|
153
|
-
function httpsGet(
|
|
154
|
-
return comReq(
|
|
153
|
+
function httpsGet(reqData, comReqOpt) {
|
|
154
|
+
return comReq(reqData, {
|
|
155
155
|
...comReqOpt,
|
|
156
156
|
method: "GET",
|
|
157
157
|
protocol: "https",
|
|
@@ -160,12 +160,12 @@ var UtilCom;
|
|
|
160
160
|
UtilCom.httpsGet = httpsGet;
|
|
161
161
|
/**发送一个 http GET 请求并接受数据
|
|
162
162
|
* @async
|
|
163
|
-
* @param
|
|
163
|
+
* @param reqData - 数据对象
|
|
164
164
|
* @param comReqOpt - 请求参数
|
|
165
165
|
* @returns 结果 undefined 为未能成功接收
|
|
166
166
|
*/
|
|
167
|
-
function httpGet(
|
|
168
|
-
return comReq(
|
|
167
|
+
function httpGet(reqData, comReqOpt) {
|
|
168
|
+
return comReq(reqData, {
|
|
169
169
|
...comReqOpt,
|
|
170
170
|
method: "GET",
|
|
171
171
|
protocol: "http",
|
|
@@ -174,7 +174,7 @@ var UtilCom;
|
|
|
174
174
|
UtilCom.httpGet = httpGet;
|
|
175
175
|
/**重复一个 https POST请求并接受数据
|
|
176
176
|
* @async
|
|
177
|
-
* @param
|
|
177
|
+
* @param reqData - 数据对象
|
|
178
178
|
* @param comReqOpt - 请求参数
|
|
179
179
|
* @param verifyFn - 判断有效性函数
|
|
180
180
|
* @param repeatOpt - 可选参数
|
|
@@ -183,8 +183,8 @@ var UtilCom;
|
|
|
183
183
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
184
184
|
* @returns 结果 undefined 为未能成功接收
|
|
185
185
|
*/
|
|
186
|
-
function httpsRepeatPost(
|
|
187
|
-
return repeatComReq(
|
|
186
|
+
function httpsRepeatPost(reqData, comReqOpt, verifyFn, repeatOpt) {
|
|
187
|
+
return repeatComReq(reqData, {
|
|
188
188
|
...comReqOpt,
|
|
189
189
|
method: "POST",
|
|
190
190
|
protocol: "https",
|
|
@@ -193,7 +193,7 @@ var UtilCom;
|
|
|
193
193
|
UtilCom.httpsRepeatPost = httpsRepeatPost;
|
|
194
194
|
/**重复一个 http POST请求并接受数据
|
|
195
195
|
* @async
|
|
196
|
-
* @param
|
|
196
|
+
* @param reqData - 数据对象
|
|
197
197
|
* @param comReqOpt - 请求参数
|
|
198
198
|
* @param verifyFn - 判断有效性函数
|
|
199
199
|
* @param repeatOpt - 可选参数
|
|
@@ -202,8 +202,8 @@ var UtilCom;
|
|
|
202
202
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
203
203
|
* @returns 结果 undefined 为未能成功接收
|
|
204
204
|
*/
|
|
205
|
-
function httpRepeatPost(
|
|
206
|
-
return repeatComReq(
|
|
205
|
+
function httpRepeatPost(reqData, comReqOpt, verifyFn, repeatOpt) {
|
|
206
|
+
return repeatComReq(reqData, {
|
|
207
207
|
...comReqOpt,
|
|
208
208
|
method: "POST",
|
|
209
209
|
protocol: "http",
|
|
@@ -212,7 +212,7 @@ var UtilCom;
|
|
|
212
212
|
UtilCom.httpRepeatPost = httpRepeatPost;
|
|
213
213
|
/**重复一个 https GET 请求并接受数据
|
|
214
214
|
* @async
|
|
215
|
-
* @param
|
|
215
|
+
* @param reqData - 数据对象
|
|
216
216
|
* @param comReqOpt - 请求参数
|
|
217
217
|
* @param verifyFn - 判断有效性函数
|
|
218
218
|
* @param repeatOpt - 可选参数
|
|
@@ -221,8 +221,8 @@ var UtilCom;
|
|
|
221
221
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
222
222
|
* @returns 结果 undefined 为未能成功接收
|
|
223
223
|
*/
|
|
224
|
-
function httpsRepeatGet(
|
|
225
|
-
return repeatComReq(
|
|
224
|
+
function httpsRepeatGet(reqData, comReqOpt, verifyFn, repeatOpt) {
|
|
225
|
+
return repeatComReq(reqData, {
|
|
226
226
|
...comReqOpt,
|
|
227
227
|
method: "GET",
|
|
228
228
|
protocol: "https",
|
|
@@ -231,7 +231,7 @@ var UtilCom;
|
|
|
231
231
|
UtilCom.httpsRepeatGet = httpsRepeatGet;
|
|
232
232
|
/**重复一个 http GET 请求并接受数据
|
|
233
233
|
* @async
|
|
234
|
-
* @param
|
|
234
|
+
* @param reqData - 数据对象
|
|
235
235
|
* @param comReqOpt - 请求参数
|
|
236
236
|
* @param verifyFn - 判断有效性函数
|
|
237
237
|
* @param repeatOpt - 可选参数
|
|
@@ -240,8 +240,8 @@ var UtilCom;
|
|
|
240
240
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
241
241
|
* @returns 结果 undefined 为未能成功接收
|
|
242
242
|
*/
|
|
243
|
-
function httpRepeatGet(
|
|
244
|
-
return repeatComReq(
|
|
243
|
+
function httpRepeatGet(reqData, comReqOpt, verifyFn, repeatOpt) {
|
|
244
|
+
return repeatComReq(reqData, {
|
|
245
245
|
...comReqOpt,
|
|
246
246
|
method: "GET",
|
|
247
247
|
protocol: "http",
|
package/package.json
CHANGED
package/src/UtilCom.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyString, JObject, ReqVerifyFn } from "@src/UtilInterfaces";
|
|
1
|
+
import { AnyString, JObject, PRecord, ReqVerifyFn } from "@src/UtilInterfaces";
|
|
2
2
|
import https from 'https';
|
|
3
3
|
import http from 'http';
|
|
4
4
|
import { SLogger } from "@src/UtilLogger";
|
|
@@ -24,7 +24,7 @@ export type ComRequestOption = {
|
|
|
24
24
|
'Content-Type'?: 'application/json'|AnyString;
|
|
25
25
|
/**内容长度 一般无需填写 应为buffer长度而非字符串长度 */
|
|
26
26
|
'Content-Length'?: number;
|
|
27
|
-
}
|
|
27
|
+
}&Record<string,string|number|boolean>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
type HttpResp = {
|
|
@@ -40,12 +40,12 @@ type HttpResp = {
|
|
|
40
40
|
export namespace UtilCom{
|
|
41
41
|
|
|
42
42
|
/**通用post处理
|
|
43
|
-
* @param
|
|
43
|
+
* @param reqData - 数据对象
|
|
44
44
|
* @param comReqOpt - 请求参数
|
|
45
45
|
* @param timeLimit - 超时时间/秒 最小为10秒
|
|
46
46
|
* @returns 结果 undefined 为未能成功接收
|
|
47
47
|
*/
|
|
48
|
-
function comReq(
|
|
48
|
+
function comReq(reqData:JObject|undefined,comReqOpt:ComRequestOption):Promise<HttpResp|undefined>{
|
|
49
49
|
let {protocol,timeLimit,...baseOpt} = comReqOpt;
|
|
50
50
|
|
|
51
51
|
//转换为毫秒
|
|
@@ -56,10 +56,10 @@ function comReq(json:JObject,comReqOpt:ComRequestOption):Promise<HttpResp|undefi
|
|
|
56
56
|
const isPost = baseOpt.method=="POST";
|
|
57
57
|
const isHttps = protocol=="https";
|
|
58
58
|
|
|
59
|
-
const jsonStr = isPost ? UtilFunc.stringifyJToken(
|
|
59
|
+
const jsonStr = isPost ? reqData!=undefined ? UtilFunc.stringifyJToken(reqData) : '' : '';
|
|
60
60
|
const funcName = `${protocol}${baseOpt.method}`;
|
|
61
61
|
|
|
62
|
-
if(!isPost) baseOpt.path += `?${qs.stringify(
|
|
62
|
+
if(!isPost && reqData!=undefined) baseOpt.path += `?${qs.stringify(reqData as any)}`;
|
|
63
63
|
|
|
64
64
|
return new Promise((resolve, rejecte)=>{
|
|
65
65
|
const resFunc = (res:http.IncomingMessage)=>{
|
|
@@ -114,8 +114,8 @@ function comReq(json:JObject,comReqOpt:ComRequestOption):Promise<HttpResp|undefi
|
|
|
114
114
|
};
|
|
115
115
|
//路由 http/https
|
|
116
116
|
const req:http.ClientRequest= isHttps
|
|
117
|
-
? https.request(baseOpt, resFunc)
|
|
118
|
-
: http.request(baseOpt, resFunc);
|
|
117
|
+
? https.request(baseOpt as JObject, resFunc)
|
|
118
|
+
: http.request(baseOpt as JObject, resFunc);
|
|
119
119
|
|
|
120
120
|
//请求超时
|
|
121
121
|
if(hasTimeLimit){
|
|
@@ -129,14 +129,14 @@ function comReq(json:JObject,comReqOpt:ComRequestOption):Promise<HttpResp|undefi
|
|
|
129
129
|
SLogger.warn(`${funcName} 发送请求错误:${e}`);
|
|
130
130
|
resolve(undefined);
|
|
131
131
|
});
|
|
132
|
-
if(
|
|
132
|
+
if(isPost && reqData!=undefined) req.write(jsonStr);
|
|
133
133
|
req.end();
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**通用重复post处理
|
|
138
138
|
* @async
|
|
139
|
-
* @param
|
|
139
|
+
* @param reqData - 数据对象
|
|
140
140
|
* @param comReqOpt - 请求参数
|
|
141
141
|
* @param verifyFn - 判断有效性函数
|
|
142
142
|
* @param repeatOpt - 可选参数
|
|
@@ -145,22 +145,22 @@ function comReq(json:JObject,comReqOpt:ComRequestOption):Promise<HttpResp|undefi
|
|
|
145
145
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
146
146
|
* @returns 结果 undefined 为未能成功接收
|
|
147
147
|
*/
|
|
148
|
-
async function repeatComReq(
|
|
148
|
+
async function repeatComReq(reqData:JObject|undefined,comReqOpt:ComRequestOption,verifyFn?:ReqVerifyFn<JObject|undefined>,repeatOpt:RepeatPromiseOpt={}):
|
|
149
149
|
Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
150
150
|
repeatOpt.tryDelay = repeatOpt.tryDelay??1;
|
|
151
151
|
|
|
152
|
-
const procFn = ()=>comReq(
|
|
152
|
+
const procFn = ()=>comReq(reqData,comReqOpt);
|
|
153
153
|
return UtilFunc.repeatPromise(procFn,verifyFn,repeatOpt);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/**发送一个 https POST 请求并接受数据
|
|
157
157
|
* @async
|
|
158
|
-
* @param
|
|
158
|
+
* @param reqData - 数据对象
|
|
159
159
|
* @param comReqOpt - 请求参数
|
|
160
160
|
* @returns 结果 undefined 为未能成功接收
|
|
161
161
|
*/
|
|
162
|
-
export function httpsPost(
|
|
163
|
-
return comReq(
|
|
162
|
+
export function httpsPost(reqData:JObject|undefined,comReqOpt:Omit<ComRequestOption,'protocol'|'method'>):Promise<HttpResp|undefined>{
|
|
163
|
+
return comReq(reqData,{
|
|
164
164
|
...comReqOpt,
|
|
165
165
|
method:"POST",
|
|
166
166
|
protocol:"https",
|
|
@@ -169,12 +169,12 @@ export function httpsPost(json:JObject,comReqOpt:Omit<ComRequestOption,'protocol
|
|
|
169
169
|
|
|
170
170
|
/**发送一个 http POST 请求并接受数据
|
|
171
171
|
* @async
|
|
172
|
-
* @param
|
|
172
|
+
* @param reqData - 数据对象
|
|
173
173
|
* @param comReqOpt - 请求参数
|
|
174
174
|
* @returns 结果 undefined 为未能成功接收
|
|
175
175
|
*/
|
|
176
|
-
export function httpPost(
|
|
177
|
-
return comReq(
|
|
176
|
+
export function httpPost(reqData:JObject|undefined,comReqOpt:Omit<ComRequestOption,'protocol'|'method'>):Promise<HttpResp|undefined>{
|
|
177
|
+
return comReq(reqData,{
|
|
178
178
|
...comReqOpt,
|
|
179
179
|
method:"POST",
|
|
180
180
|
protocol:"http",
|
|
@@ -182,12 +182,12 @@ export function httpPost(json:JObject,comReqOpt:Omit<ComRequestOption,'protocol'
|
|
|
182
182
|
}
|
|
183
183
|
/**发送一个 https GET 请求并接受数据
|
|
184
184
|
* @async
|
|
185
|
-
* @param
|
|
185
|
+
* @param reqData - 数据对象
|
|
186
186
|
* @param comReqOpt - 请求参数
|
|
187
187
|
* @returns 结果 undefined 为未能成功接收
|
|
188
188
|
*/
|
|
189
|
-
export function httpsGet(
|
|
190
|
-
return comReq(
|
|
189
|
+
export function httpsGet(reqData:JObject|undefined,comReqOpt:Omit<ComRequestOption,'protocol'|'method'>):Promise<HttpResp|undefined>{
|
|
190
|
+
return comReq(reqData,{
|
|
191
191
|
...comReqOpt,
|
|
192
192
|
method:"GET",
|
|
193
193
|
protocol:"https",
|
|
@@ -196,12 +196,12 @@ export function httpsGet(json:JObject,comReqOpt:Omit<ComRequestOption,'protocol'
|
|
|
196
196
|
|
|
197
197
|
/**发送一个 http GET 请求并接受数据
|
|
198
198
|
* @async
|
|
199
|
-
* @param
|
|
199
|
+
* @param reqData - 数据对象
|
|
200
200
|
* @param comReqOpt - 请求参数
|
|
201
201
|
* @returns 结果 undefined 为未能成功接收
|
|
202
202
|
*/
|
|
203
|
-
export function httpGet(
|
|
204
|
-
return comReq(
|
|
203
|
+
export function httpGet(reqData:JObject|undefined,comReqOpt:Omit<ComRequestOption,'protocol'|'method'>):Promise<HttpResp|undefined>{
|
|
204
|
+
return comReq(reqData,{
|
|
205
205
|
...comReqOpt,
|
|
206
206
|
method:"GET",
|
|
207
207
|
protocol:"http",
|
|
@@ -211,7 +211,7 @@ export function httpGet(json:JObject,comReqOpt:Omit<ComRequestOption,'protocol'|
|
|
|
211
211
|
|
|
212
212
|
/**重复一个 https POST请求并接受数据
|
|
213
213
|
* @async
|
|
214
|
-
* @param
|
|
214
|
+
* @param reqData - 数据对象
|
|
215
215
|
* @param comReqOpt - 请求参数
|
|
216
216
|
* @param verifyFn - 判断有效性函数
|
|
217
217
|
* @param repeatOpt - 可选参数
|
|
@@ -220,9 +220,9 @@ export function httpGet(json:JObject,comReqOpt:Omit<ComRequestOption,'protocol'|
|
|
|
220
220
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
221
221
|
* @returns 结果 undefined 为未能成功接收
|
|
222
222
|
*/
|
|
223
|
-
export function httpsRepeatPost(
|
|
223
|
+
export function httpsRepeatPost(reqData:JObject|undefined,comReqOpt:Omit<ComRequestOption,'protocol'|'method'>,verifyFn?:ReqVerifyFn<JObject|undefined>,repeatOpt?:RepeatPromiseOpt):
|
|
224
224
|
Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
225
|
-
return repeatComReq(
|
|
225
|
+
return repeatComReq(reqData,{
|
|
226
226
|
...comReqOpt,
|
|
227
227
|
method:"POST",
|
|
228
228
|
protocol:"https",
|
|
@@ -231,7 +231,7 @@ Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
|
231
231
|
|
|
232
232
|
/**重复一个 http POST请求并接受数据
|
|
233
233
|
* @async
|
|
234
|
-
* @param
|
|
234
|
+
* @param reqData - 数据对象
|
|
235
235
|
* @param comReqOpt - 请求参数
|
|
236
236
|
* @param verifyFn - 判断有效性函数
|
|
237
237
|
* @param repeatOpt - 可选参数
|
|
@@ -240,9 +240,9 @@ Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
|
240
240
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
241
241
|
* @returns 结果 undefined 为未能成功接收
|
|
242
242
|
*/
|
|
243
|
-
export function httpRepeatPost(
|
|
243
|
+
export function httpRepeatPost(reqData:JObject|undefined,comReqOpt:Omit<ComRequestOption,'protocol'|'method'>,verifyFn?:ReqVerifyFn<JObject|undefined>,repeatOpt?:RepeatPromiseOpt):
|
|
244
244
|
Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
245
|
-
return repeatComReq(
|
|
245
|
+
return repeatComReq(reqData,{
|
|
246
246
|
...comReqOpt,
|
|
247
247
|
method:"POST",
|
|
248
248
|
protocol:"http",
|
|
@@ -251,7 +251,7 @@ Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
|
251
251
|
|
|
252
252
|
/**重复一个 https GET 请求并接受数据
|
|
253
253
|
* @async
|
|
254
|
-
* @param
|
|
254
|
+
* @param reqData - 数据对象
|
|
255
255
|
* @param comReqOpt - 请求参数
|
|
256
256
|
* @param verifyFn - 判断有效性函数
|
|
257
257
|
* @param repeatOpt - 可选参数
|
|
@@ -260,9 +260,9 @@ Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
|
260
260
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
261
261
|
* @returns 结果 undefined 为未能成功接收
|
|
262
262
|
*/
|
|
263
|
-
export function httpsRepeatGet(
|
|
263
|
+
export function httpsRepeatGet(reqData:JObject|undefined,comReqOpt:Omit<ComRequestOption,'protocol'|'method'>,verifyFn?:ReqVerifyFn<JObject|undefined>,repeatOpt?:RepeatPromiseOpt):
|
|
264
264
|
Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
265
|
-
return repeatComReq(
|
|
265
|
+
return repeatComReq(reqData,{
|
|
266
266
|
...comReqOpt,
|
|
267
267
|
method:"GET",
|
|
268
268
|
protocol:"https",
|
|
@@ -271,7 +271,7 @@ Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
|
271
271
|
|
|
272
272
|
/**重复一个 http GET 请求并接受数据
|
|
273
273
|
* @async
|
|
274
|
-
* @param
|
|
274
|
+
* @param reqData - 数据对象
|
|
275
275
|
* @param comReqOpt - 请求参数
|
|
276
276
|
* @param verifyFn - 判断有效性函数
|
|
277
277
|
* @param repeatOpt - 可选参数
|
|
@@ -280,9 +280,9 @@ Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
|
280
280
|
* @param opt.tryDelay - 重试间隔时间/秒 默认 1
|
|
281
281
|
* @returns 结果 undefined 为未能成功接收
|
|
282
282
|
*/
|
|
283
|
-
export function httpRepeatGet(
|
|
283
|
+
export function httpRepeatGet(reqData:JObject|undefined,comReqOpt:Omit<ComRequestOption,'protocol'|'method'>,verifyFn?:ReqVerifyFn<JObject|undefined>,repeatOpt?:RepeatPromiseOpt):
|
|
284
284
|
Promise<RepeatPromiseResult<HttpResp|undefined>|undefined>{
|
|
285
|
-
return repeatComReq(
|
|
285
|
+
return repeatComReq(reqData,{
|
|
286
286
|
...comReqOpt,
|
|
287
287
|
method:"GET",
|
|
288
288
|
protocol:"http",
|