@less-is-more/less-js 1.4.37 → 1.4.39-0
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/package.json +1 -1
- package/src/router.js +7 -4
package/package.json
CHANGED
package/src/router.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const Ret = require("./ret.js");
|
|
2
2
|
const Param = require("./param.js");
|
|
3
3
|
const qs = require("qs");
|
|
4
|
-
const
|
|
4
|
+
const getBody = require("body");
|
|
5
5
|
const multiparty = require("multiparty");
|
|
6
6
|
const { promisify } = require("util");
|
|
7
7
|
const zlib = require("zlib");
|
|
@@ -46,7 +46,7 @@ module.exports = class Router {
|
|
|
46
46
|
// 转换后调用原来的方法
|
|
47
47
|
await this.route(targets, req, res, context);
|
|
48
48
|
return {
|
|
49
|
-
statusCode: 200,
|
|
49
|
+
statusCode: res.statusCode || 200,
|
|
50
50
|
headers: Object.assign(res.headers || {}, event.resHeaders || {}),
|
|
51
51
|
body: res.content.toString("base64"),
|
|
52
52
|
isBase64Encoded: true,
|
|
@@ -149,7 +149,9 @@ module.exports = class Router {
|
|
|
149
149
|
if (isFile) {
|
|
150
150
|
await this._getFile(req);
|
|
151
151
|
} else if (isJson) {
|
|
152
|
-
|
|
152
|
+
// 3.0是有body的,2.0是没有body的
|
|
153
|
+
const data =
|
|
154
|
+
req.body == undefined ? await promisify(getBody)(req) : req.body;
|
|
153
155
|
if (!Param.isBlank(data)) {
|
|
154
156
|
try {
|
|
155
157
|
req.sourceBody = data.toString();
|
|
@@ -159,7 +161,8 @@ module.exports = class Router {
|
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
} else {
|
|
162
|
-
const data =
|
|
164
|
+
const data =
|
|
165
|
+
req.body == undefined ? await promisify(getBody)(req) : req.body;
|
|
163
166
|
try {
|
|
164
167
|
req.sourceBody = decodeURIComponent(data.toString());
|
|
165
168
|
} catch (e) {
|