@faasjs/http 0.0.2-beta.255 → 0.0.2-beta.260

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/lib/index.es.js CHANGED
@@ -394,10 +394,11 @@ class Http {
394
394
  this.logger.debug('[onInvoke] Parse params from queryString');
395
395
  this.params = data.event.queryString;
396
396
  }
397
+ this.logger.debug('[onInvoke] Params: %j', this.params);
397
398
  this.logger.debug('[onInvoke] Parse cookie');
398
399
  this.cookie.invoke(this.headers.cookie);
399
- this.logger.debug('[onInvoke] Cookie: %O', this.cookie.content);
400
- this.logger.debug('[onInvoke] Session: %O', this.session.content);
400
+ this.logger.debug('[onInvoke] Cookie: %j', this.cookie.content);
401
+ this.logger.debug('[onInvoke] Session: %j', this.session.content);
401
402
  if (this.validator && data.event.httpMethod) {
402
403
  this.logger.debug('[onInvoke] Valid request');
403
404
  try {
@@ -456,10 +457,15 @@ class Http {
456
457
  'X-SCF-RequestId': data.context.request_id
457
458
  }, this.cookie.headers(), this.response.headers);
458
459
  data.response = this.response;
459
- // 非字符串和 JSON 格式的响应不压缩
460
+ if (process.env.FaasMode === 'local') {
461
+ this.logger.debug('[onInvoke] Response: %j', data.response);
462
+ return;
463
+ }
464
+ // 判断是否需要压缩
460
465
  if (data.response.isBase64Encoded ||
461
466
  typeof data.response.body !== 'string' ||
462
- !((_b = data.response.headers['Content-Type']) === null || _b === void 0 ? void 0 : _b.includes('json')))
467
+ !((_b = data.response.headers['Content-Type']) === null || _b === void 0 ? void 0 : _b.includes('json')) ||
468
+ data.response.body.length < 100)
463
469
  return;
464
470
  const acceptEncoding = this.headers['accept-encoding'] || this.headers['Accept-Encoding'];
465
471
  if (!acceptEncoding || !/(br|gzip|deflate)/.test(acceptEncoding))
package/lib/index.js CHANGED
@@ -398,10 +398,11 @@ class Http {
398
398
  this.logger.debug('[onInvoke] Parse params from queryString');
399
399
  this.params = data.event.queryString;
400
400
  }
401
+ this.logger.debug('[onInvoke] Params: %j', this.params);
401
402
  this.logger.debug('[onInvoke] Parse cookie');
402
403
  this.cookie.invoke(this.headers.cookie);
403
- this.logger.debug('[onInvoke] Cookie: %O', this.cookie.content);
404
- this.logger.debug('[onInvoke] Session: %O', this.session.content);
404
+ this.logger.debug('[onInvoke] Cookie: %j', this.cookie.content);
405
+ this.logger.debug('[onInvoke] Session: %j', this.session.content);
405
406
  if (this.validator && data.event.httpMethod) {
406
407
  this.logger.debug('[onInvoke] Valid request');
407
408
  try {
@@ -460,10 +461,15 @@ class Http {
460
461
  'X-SCF-RequestId': data.context.request_id
461
462
  }, this.cookie.headers(), this.response.headers);
462
463
  data.response = this.response;
463
- // 非字符串和 JSON 格式的响应不压缩
464
+ if (process.env.FaasMode === 'local') {
465
+ this.logger.debug('[onInvoke] Response: %j', data.response);
466
+ return;
467
+ }
468
+ // 判断是否需要压缩
464
469
  if (data.response.isBase64Encoded ||
465
470
  typeof data.response.body !== 'string' ||
466
- !((_b = data.response.headers['Content-Type']) === null || _b === void 0 ? void 0 : _b.includes('json')))
471
+ !((_b = data.response.headers['Content-Type']) === null || _b === void 0 ? void 0 : _b.includes('json')) ||
472
+ data.response.body.length < 100)
467
473
  return;
468
474
  const acceptEncoding = this.headers['accept-encoding'] || this.headers['Accept-Encoding'];
469
475
  if (!acceptEncoding || !/(br|gzip|deflate)/.test(acceptEncoding))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/http",
3
- "version": "0.0.2-beta.255",
3
+ "version": "0.0.2-beta.260",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.es.js",
@@ -18,7 +18,7 @@
18
18
  "lib"
19
19
  ],
20
20
  "devDependencies": {
21
- "@faasjs/func": "^0.0.2-beta.255",
21
+ "@faasjs/func": "^0.0.2-beta.260",
22
22
  "@types/debug": "*",
23
23
  "@types/jest": "*",
24
24
  "@types/node": "*",
@@ -26,5 +26,5 @@
26
26
  "rollup-plugin-typescript2": "*",
27
27
  "typescript": "*"
28
28
  },
29
- "gitHead": "b44a8294ba8ed5b08cf56931f00e58fa9adfb6ce"
29
+ "gitHead": "4863d76f065e4ca18a3ec4131a630ef37c742fcf"
30
30
  }