node-easywechat 2.10.1 → 2.10.2
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/CHANGELOG.md +7 -0
- package/dist/Core/Http/Request.d.ts +2 -1
- package/dist/Core/Http/Request.js +30 -33
- package/dist/Core/Utils.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v2.10.2 (2022-05-25)
|
|
5
|
+
|
|
6
|
+
- Fix: 修复Http/Request对象传入xml时解析异常导致无法获取请求参数的问题(#27)
|
|
7
|
+
|
|
8
|
+
## v2.10.1 (2022-05-21)
|
|
9
|
+
|
|
4
10
|
## v2.10.0 (2022-05-18)
|
|
5
11
|
|
|
12
|
+
- Feat: 开放平台代理小程序新增申请隐私接口相关接口
|
|
6
13
|
- Feat: 开放平台代理小程序新增小程序用户隐私保护指引相关接口
|
|
7
14
|
- Feat: 开放平台代理小程序新增获取永久素材接口
|
|
8
15
|
- Feat: 企业微信新增商品图册相关接口
|
|
@@ -17,7 +17,8 @@ export default class Request implements RequestInterface {
|
|
|
17
17
|
get(key: string): Promise<any>;
|
|
18
18
|
post(key: string): Promise<any>;
|
|
19
19
|
getAllGet(): object;
|
|
20
|
-
getAllPost(): object
|
|
20
|
+
getAllPost(): Promise<object>;
|
|
21
|
+
private _parseContent;
|
|
21
22
|
getContent(): Promise<Buffer>;
|
|
22
23
|
getUri(): string;
|
|
23
24
|
getContentType(): string;
|
|
@@ -42,22 +42,6 @@ class Request {
|
|
|
42
42
|
this._contentType = 'application/json';
|
|
43
43
|
}
|
|
44
44
|
else if (typeof content === 'string') {
|
|
45
|
-
try {
|
|
46
|
-
this._post = JSON.parse(content);
|
|
47
|
-
this._contentType = 'application/json';
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
if (content.substr(0, 1) === '<') {
|
|
51
|
-
(0, Utils_1.parseXml)(content).then(res => {
|
|
52
|
-
this._post = res;
|
|
53
|
-
this._contentType = 'text/xml';
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this._post = (0, Utils_1.parseQueryString)(content);
|
|
58
|
-
this._contentType = 'application/x-www-form-urlencoded';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
45
|
this._content = Buffer.from(content);
|
|
62
46
|
}
|
|
63
47
|
}
|
|
@@ -120,20 +104,8 @@ class Request {
|
|
|
120
104
|
throw new Error('Please set request first. app.rebind(\'request\', new EasyWechat.Request(ctx.req));');
|
|
121
105
|
if (this._method !== 'POST')
|
|
122
106
|
return null;
|
|
123
|
-
if (!this.
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
if (!this._post && this._content) {
|
|
127
|
-
let contentType = this._contentType.toLowerCase();
|
|
128
|
-
if (contentType.indexOf('application/json') > -1) {
|
|
129
|
-
try {
|
|
130
|
-
this._post = JSON.parse(this._content.toString());
|
|
131
|
-
}
|
|
132
|
-
catch (e) { }
|
|
133
|
-
}
|
|
134
|
-
else if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
135
|
-
this._post = (0, Utils_1.parseQueryString)(this._content.toString());
|
|
136
|
-
}
|
|
107
|
+
if (!this._post) {
|
|
108
|
+
yield this._parseContent();
|
|
137
109
|
}
|
|
138
110
|
return this._post && this._post[key] != undefined ? this._post[key] : null;
|
|
139
111
|
});
|
|
@@ -144,9 +116,34 @@ class Request {
|
|
|
144
116
|
return this._get;
|
|
145
117
|
}
|
|
146
118
|
getAllPost() {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
if (!this.isValid)
|
|
121
|
+
throw new Error('Please set request first. app.rebind(\'request\', new EasyWechat.Request(ctx.req));');
|
|
122
|
+
if (!this._post) {
|
|
123
|
+
yield this._parseContent();
|
|
124
|
+
}
|
|
125
|
+
return this._post;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
_parseContent() {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
let content = (yield this.getContent()).toString();
|
|
131
|
+
try {
|
|
132
|
+
this._post = JSON.parse(content);
|
|
133
|
+
this._contentType = 'application/json';
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
if ((content).substring(0, 1) === '<') {
|
|
137
|
+
let res = yield (0, Utils_1.parseXml)(content);
|
|
138
|
+
this._post = res;
|
|
139
|
+
this._contentType = 'text/xml';
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this._post = (0, Utils_1.parseQueryString)(content);
|
|
143
|
+
this._contentType = 'application/x-www-form-urlencoded';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
150
147
|
}
|
|
151
148
|
getContent() {
|
|
152
149
|
return __awaiter(this, void 0, void 0, function* () {
|
package/dist/Core/Utils.js
CHANGED