cvitool 1.0.766 → 1.0.768
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/build/src/cutil.js +1 -1
- package/build/src/hgo.js +5 -6
- package/package.json +1 -1
- package/src/cutil.ts +1 -1
- package/src/hgo.ts +5 -1
package/build/src/cutil.js
CHANGED
|
@@ -496,7 +496,7 @@ function validate(value, rule, finalFunc) {
|
|
|
496
496
|
if (type === 'array' && subType) {
|
|
497
497
|
for (const subValue of fieldValue) {
|
|
498
498
|
if (getValueType(subValue) !== subType) {
|
|
499
|
-
result.message = `field type must be: ${
|
|
499
|
+
result.message = `field subValue type must be: ${subType}`;
|
|
500
500
|
result.pass = false;
|
|
501
501
|
return result;
|
|
502
502
|
}
|
package/build/src/hgo.js
CHANGED
|
@@ -55,12 +55,9 @@ function request(url, options) {
|
|
|
55
55
|
const isStrBodyType = (0, cutil_1.getValueType)(body) === 'string';
|
|
56
56
|
const data = (isStrBodyType ? body : JSON.stringify(body));
|
|
57
57
|
const isBodyEmpty = data.length === 0 || data === '{}';
|
|
58
|
-
let baseHeaders = {};
|
|
58
|
+
let baseHeaders = { 'User-Agent': 'Node-HttpClient' };
|
|
59
59
|
if (!isBodyEmpty) {
|
|
60
|
-
baseHeaders = {
|
|
61
|
-
'Content-Type': isStrBodyType ? 'text/plain; charset=utf-8' : 'application/json; charset=utf-8',
|
|
62
|
-
'Content-Length': Buffer.byteLength(data)
|
|
63
|
-
};
|
|
60
|
+
baseHeaders = Object.assign(Object.assign({}, baseHeaders), { 'Content-Type': isStrBodyType ? 'text/plain; charset=utf-8' : 'application/json; charset=utf-8', 'Content-Length': Buffer.byteLength(data) });
|
|
64
61
|
}
|
|
65
62
|
let res;
|
|
66
63
|
const { reqProtocol, reqOpt } = getReqProtocolAndOpt(url, baseHeaders, headers, connectTimeOut, method, agent, useEnvProxy, proxyHost);
|
|
@@ -126,6 +123,7 @@ function reqSendBuffer(url, options) {
|
|
|
126
123
|
readTimeOut = timeout;
|
|
127
124
|
}
|
|
128
125
|
const baseHeaders = {
|
|
126
|
+
'User-Agent': 'Node-HttpClient',
|
|
129
127
|
'Content-Length': buffer.byteLength
|
|
130
128
|
};
|
|
131
129
|
const { reqProtocol, reqOpt } = getReqProtocolAndOpt(url, baseHeaders, headers, connectTimeOut, method, agent, useEnvProxy, proxyHost);
|
|
@@ -187,6 +185,7 @@ function reqSendStream(url, options) {
|
|
|
187
185
|
readTimeOut = timeout;
|
|
188
186
|
}
|
|
189
187
|
const baseHeaders = {
|
|
188
|
+
'User-Agent': 'Node-HttpClient',
|
|
190
189
|
'Content-Type': 'application/octet-stream',
|
|
191
190
|
'Transfer-Encoding': 'chunked',
|
|
192
191
|
Connection: 'keep-alive'
|
|
@@ -242,7 +241,7 @@ function reqSendMultiPart(url, options) {
|
|
|
242
241
|
connectTimeOut = timeout;
|
|
243
242
|
readTimeOut = timeout;
|
|
244
243
|
}
|
|
245
|
-
const baseHeaders = Object.assign({}, form.getHeaders());
|
|
244
|
+
const baseHeaders = Object.assign({ 'User-Agent': 'Node-HttpClient' }, form.getHeaders());
|
|
246
245
|
const { reqProtocol, reqOpt } = getReqProtocolAndOpt(url, baseHeaders, headers, connectTimeOut, 'post', agent, useEnvProxy, proxyHost);
|
|
247
246
|
const res = yield new Promise((resolve, reject) => {
|
|
248
247
|
const req = reqProtocol.request(reqOpt, res => {
|
package/package.json
CHANGED
package/src/cutil.ts
CHANGED
|
@@ -522,7 +522,7 @@ function validate(value: { [key: string]: any }, rule: { [key: string]: validate
|
|
|
522
522
|
if (type === 'array' && subType) {
|
|
523
523
|
for (const subValue of fieldValue) {
|
|
524
524
|
if (getValueType(subValue) !== subType) {
|
|
525
|
-
result.message = `field type must be: ${
|
|
525
|
+
result.message = `field subValue type must be: ${subType}`;
|
|
526
526
|
result.pass = false;
|
|
527
527
|
return result;
|
|
528
528
|
}
|
package/src/hgo.ts
CHANGED
|
@@ -105,9 +105,10 @@ async function request(url: string, options?: reqOptions): Promise<ResData> {
|
|
|
105
105
|
const isStrBodyType = getValueType(body) === 'string';
|
|
106
106
|
const data = (isStrBodyType ? body : JSON.stringify(body)) as string;
|
|
107
107
|
const isBodyEmpty = data.length === 0 || data === '{}';
|
|
108
|
-
let baseHeaders: CustomObject = {};
|
|
108
|
+
let baseHeaders: CustomObject = { 'User-Agent': 'Node-HttpClient' };
|
|
109
109
|
if (!isBodyEmpty) {
|
|
110
110
|
baseHeaders = {
|
|
111
|
+
...baseHeaders,
|
|
111
112
|
'Content-Type': isStrBodyType ? 'text/plain; charset=utf-8' : 'application/json; charset=utf-8',
|
|
112
113
|
'Content-Length': Buffer.byteLength(data)
|
|
113
114
|
};
|
|
@@ -176,6 +177,7 @@ async function reqSendBuffer(url: string, options: reqSendBufferOptions): Promis
|
|
|
176
177
|
readTimeOut = timeout;
|
|
177
178
|
}
|
|
178
179
|
const baseHeaders = {
|
|
180
|
+
'User-Agent': 'Node-HttpClient',
|
|
179
181
|
'Content-Length': buffer.byteLength
|
|
180
182
|
};
|
|
181
183
|
const { reqProtocol, reqOpt } = getReqProtocolAndOpt(url, baseHeaders, headers, connectTimeOut, method, agent, useEnvProxy, proxyHost);
|
|
@@ -238,6 +240,7 @@ async function reqSendStream(url: string, options: reqSendStreamOptions): Promis
|
|
|
238
240
|
readTimeOut = timeout;
|
|
239
241
|
}
|
|
240
242
|
const baseHeaders = {
|
|
243
|
+
'User-Agent': 'Node-HttpClient',
|
|
241
244
|
'Content-Type': 'application/octet-stream',
|
|
242
245
|
'Transfer-Encoding': 'chunked',
|
|
243
246
|
Connection: 'keep-alive'
|
|
@@ -296,6 +299,7 @@ async function reqSendMultiPart(url: string, options: reqSendMultiPartOptions):
|
|
|
296
299
|
readTimeOut = timeout;
|
|
297
300
|
}
|
|
298
301
|
const baseHeaders = {
|
|
302
|
+
'User-Agent': 'Node-HttpClient',
|
|
299
303
|
...form.getHeaders()
|
|
300
304
|
};
|
|
301
305
|
const { reqProtocol, reqOpt } = getReqProtocolAndOpt(url, baseHeaders, headers, connectTimeOut, 'post', agent, useEnvProxy, proxyHost);
|