cgserver 9.1.6 → 9.1.7
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/README.md
CHANGED
|
@@ -7,6 +7,13 @@ const Log_1 = require("./Log");
|
|
|
7
7
|
const Core_1 = require("../Core/Core");
|
|
8
8
|
exports.GHttpTool = null;
|
|
9
9
|
class HttpTool {
|
|
10
|
+
_debug = false;
|
|
11
|
+
get debug() {
|
|
12
|
+
return this._debug;
|
|
13
|
+
}
|
|
14
|
+
set debug(value) {
|
|
15
|
+
this._debug = value;
|
|
16
|
+
}
|
|
10
17
|
get(options_url) {
|
|
11
18
|
let options = null;
|
|
12
19
|
if (Core_1.core.isString(options_url)) {
|
|
@@ -15,6 +22,9 @@ class HttpTool {
|
|
|
15
22
|
else {
|
|
16
23
|
options = options_url;
|
|
17
24
|
}
|
|
25
|
+
if (this._debug) {
|
|
26
|
+
Log_1.GLog.info("prepare get:" + options.url);
|
|
27
|
+
}
|
|
18
28
|
return new Promise((resolve, reject) => {
|
|
19
29
|
request.get(options, (error, response, body) => {
|
|
20
30
|
let originbody = body;
|
|
@@ -35,6 +45,12 @@ class HttpTool {
|
|
|
35
45
|
body = originbody;
|
|
36
46
|
}
|
|
37
47
|
}
|
|
48
|
+
if (this._debug) {
|
|
49
|
+
Log_1.GLog.info({
|
|
50
|
+
url: options.url,
|
|
51
|
+
originbody: originbody
|
|
52
|
+
});
|
|
53
|
+
}
|
|
38
54
|
resolve({ error, response, body, originbody });
|
|
39
55
|
});
|
|
40
56
|
});
|
|
@@ -47,6 +63,9 @@ class HttpTool {
|
|
|
47
63
|
else {
|
|
48
64
|
options = options_url;
|
|
49
65
|
}
|
|
66
|
+
if (this._debug) {
|
|
67
|
+
Log_1.GLog.info("prepare post:" + options.url);
|
|
68
|
+
}
|
|
50
69
|
return new Promise((resolve, reject) => {
|
|
51
70
|
request.post(options, (error, response, body) => {
|
|
52
71
|
let originbody = body;
|
|
@@ -67,6 +86,12 @@ class HttpTool {
|
|
|
67
86
|
body = originbody;
|
|
68
87
|
}
|
|
69
88
|
}
|
|
89
|
+
if (this._debug) {
|
|
90
|
+
Log_1.GLog.info({
|
|
91
|
+
url: options.url,
|
|
92
|
+
originbody: originbody
|
|
93
|
+
});
|
|
94
|
+
}
|
|
70
95
|
resolve({ error, response, body, originbody });
|
|
71
96
|
});
|
|
72
97
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as request from "request";
|
|
2
2
|
export declare let GHttpTool: HttpTool;
|
|
3
3
|
declare class HttpTool {
|
|
4
|
+
protected _debug: boolean;
|
|
5
|
+
get debug(): boolean;
|
|
6
|
+
set debug(value: boolean);
|
|
4
7
|
get(options_url: request.OptionsWithUrl | string): Promise<{
|
|
5
8
|
error: any;
|
|
6
9
|
response: any;
|