@maiyunnet/kebab 9.1.0 → 9.1.1

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/doc/kebab-rag.md CHANGED
@@ -1355,7 +1355,7 @@ index/variables/VER.md
1355
1355
 
1356
1356
  # Variable: VER
1357
1357
 
1358
- > `const` **VER**: `"9.1.0"` = `'9.1.0'`
1358
+ > `const` **VER**: `"9.1.1"` = `'9.1.1'`
1359
1359
 
1360
1360
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1361
1361
 
@@ -13049,7 +13049,7 @@ Defined in: [lib/session.ts:39](https://github.com/maiyunnet/kebab/blob/master/l
13049
13049
 
13050
13050
  > **getName**(): `string`
13051
13051
 
13052
- Defined in: [lib/session.ts:207](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L207)
13052
+ Defined in: [lib/session.ts:212](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L212)
13053
13053
 
13054
13054
  获取当前的 cookie 的 name 值
13055
13055
 
@@ -13063,7 +13063,7 @@ Defined in: [lib/session.ts:207](https://github.com/maiyunnet/kebab/blob/master/
13063
13063
 
13064
13064
  > **getToken**(): `string`
13065
13065
 
13066
- Defined in: [lib/session.ts:200](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L200)
13066
+ Defined in: [lib/session.ts:205](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L205)
13067
13067
 
13068
13068
  获取当前的 token 值
13069
13069
 
@@ -13119,7 +13119,7 @@ false 表示系统错误
13119
13119
 
13120
13120
  > **update**(): `Promise`\<`void`\>
13121
13121
 
13122
- Defined in: [lib/session.ts:214](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L214)
13122
+ Defined in: [lib/session.ts:219](https://github.com/maiyunnet/kebab/blob/master/lib/session.ts#L219)
13123
13123
 
13124
13124
  页面整体结束时,要写入到 Kv 或 数据库
13125
13125
 
@@ -20199,7 +20199,7 @@ Defined in: [sys/ctr.ts:120](https://github.com/maiyunnet/kebab/blob/master/sys/
20199
20199
 
20200
20200
  Defined in: [sys/ctr.ts:132](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L132)
20201
20201
 
20202
- 获取当前过期时间
20202
+ 获取当前过期时间(毫秒)
20203
20203
 
20204
20204
  ##### Returns
20205
20205
 
@@ -20211,7 +20211,7 @@ Defined in: [sys/ctr.ts:132](https://github.com/maiyunnet/kebab/blob/master/sys/
20211
20211
 
20212
20212
  Defined in: [sys/ctr.ts:139](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L139)
20213
20213
 
20214
- 设置当前过期时间
20214
+ 设置当前过期时间(毫秒)
20215
20215
 
20216
20216
  ##### Parameters
20217
20217
 
@@ -20319,7 +20319,7 @@ Defined in: [sys/ctr.ts:746](https://github.com/maiyunnet/kebab/blob/master/sys/
20319
20319
 
20320
20320
  > `protected` **\_cross**(`opt?`): `boolean`
20321
20321
 
20322
- Defined in: [sys/ctr.ts:960](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L960)
20322
+ Defined in: [sys/ctr.ts:975](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L975)
20323
20323
 
20324
20324
  开启跨域请求
20325
20325
 
@@ -20401,7 +20401,7 @@ Defined in: [sys/ctr.ts:757](https://github.com/maiyunnet/kebab/blob/master/sys/
20401
20401
 
20402
20402
  > `protected` **\_end**(): `void`
20403
20403
 
20404
- Defined in: [sys/ctr.ts:1068](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1068)
20404
+ Defined in: [sys/ctr.ts:1083](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1083)
20405
20405
 
20406
20406
  主动关闭当前 socket 连接
20407
20407
 
@@ -20443,7 +20443,7 @@ Defined in: [sys/ctr.ts:781](https://github.com/maiyunnet/kebab/blob/master/sys/
20443
20443
 
20444
20444
  > `protected` **\_getLocale**(): `string`
20445
20445
 
20446
- Defined in: [sys/ctr.ts:951](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L951)
20446
+ Defined in: [sys/ctr.ts:966](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L966)
20447
20447
 
20448
20448
  获取当前语言名
20449
20449
 
@@ -20457,7 +20457,7 @@ Defined in: [sys/ctr.ts:951](https://github.com/maiyunnet/kebab/blob/master/sys/
20457
20457
 
20458
20458
  > `protected` **\_getLocaleJsonString**(): `string`
20459
20459
 
20460
- Defined in: [sys/ctr.ts:939](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L939)
20460
+ Defined in: [sys/ctr.ts:954](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L954)
20461
20461
 
20462
20462
  根据当前后台语言包设置情况获取 JSON 字符串传输到前台
20463
20463
 
@@ -20509,7 +20509,7 @@ Defined in: [sys/ctr.ts:315](https://github.com/maiyunnet/kebab/blob/master/sys/
20509
20509
 
20510
20510
  > `protected` **\_handleFormData**(`events?`, `limits?`): `Promise`\<`boolean`\>
20511
20511
 
20512
- Defined in: [sys/ctr.ts:1077](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1077)
20512
+ Defined in: [sys/ctr.ts:1092](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1092)
20513
20513
 
20514
20514
  获取 formdata 的信息
20515
20515
 
@@ -20557,7 +20557,7 @@ Defined in: [sys/ctr.ts:1077](https://github.com/maiyunnet/kebab/blob/master/sys
20557
20557
 
20558
20558
  > **\_l**(`key`, `data?`): `string`
20559
20559
 
20560
- Defined in: [sys/ctr.ts:1003](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1003)
20560
+ Defined in: [sys/ctr.ts:1018](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1018)
20561
20561
 
20562
20562
  获取语言包值
20563
20563
 
@@ -20583,7 +20583,7 @@ Defined in: [sys/ctr.ts:1003](https://github.com/maiyunnet/kebab/blob/master/sys
20583
20583
 
20584
20584
  > `protected` **\_loadData**(`path`): `Promise`\<`Record`\<`string`, `string`\> \| `null`\>
20585
20585
 
20586
- Defined in: [sys/ctr.ts:842](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L842)
20586
+ Defined in: [sys/ctr.ts:857](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L857)
20587
20587
 
20588
20588
  获取 data 数据
20589
20589
 
@@ -20605,7 +20605,7 @@ Defined in: [sys/ctr.ts:842](https://github.com/maiyunnet/kebab/blob/master/sys/
20605
20605
 
20606
20606
  > `protected` **\_loadLocale**(`loc`, `pkg?`): `Promise`\<`boolean`\>
20607
20607
 
20608
- Defined in: [sys/ctr.ts:890](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L890)
20608
+ Defined in: [sys/ctr.ts:905](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L905)
20609
20609
 
20610
20610
  设定语言并加载语言包
20611
20611
 
@@ -20726,7 +20726,7 @@ Defined in: [sys/ctr.ts:332](https://github.com/maiyunnet/kebab/blob/master/sys/
20726
20726
 
20727
20727
  > `protected` **\_location**(`location`): `false`
20728
20728
 
20729
- Defined in: [sys/ctr.ts:860](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L860)
20729
+ Defined in: [sys/ctr.ts:875](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L875)
20730
20730
 
20731
20731
  跳转(302临时跳转),支持相对本项目根路径的路径或绝对路径
20732
20732
 
@@ -20748,7 +20748,7 @@ Defined in: [sys/ctr.ts:860](https://github.com/maiyunnet/kebab/blob/master/sys/
20748
20748
 
20749
20749
  > `protected` **\_ping**(`data?`): `boolean`
20750
20750
 
20751
- Defined in: [sys/ctr.ts:1053](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1053)
20751
+ Defined in: [sys/ctr.ts:1068](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1068)
20752
20752
 
20753
20753
  发送 socket ping
20754
20754
 
@@ -20770,7 +20770,7 @@ Defined in: [sys/ctr.ts:1053](https://github.com/maiyunnet/kebab/blob/master/sys
20770
20770
 
20771
20771
  > `protected` **\_pong**(`data?`): `boolean`
20772
20772
 
20773
- Defined in: [sys/ctr.ts:1061](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1061)
20773
+ Defined in: [sys/ctr.ts:1076](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1076)
20774
20774
 
20775
20775
  发送 socket pong
20776
20776
 
@@ -20792,7 +20792,7 @@ Defined in: [sys/ctr.ts:1061](https://github.com/maiyunnet/kebab/blob/master/sys
20792
20792
 
20793
20793
  > `protected` **\_startSession**(`link`, `auth?`, `opt?`): `Promise`\<`boolean`\>
20794
20794
 
20795
- Defined in: [sys/ctr.ts:874](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L874)
20795
+ Defined in: [sys/ctr.ts:889](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L889)
20796
20796
 
20797
20797
  开启 Session
20798
20798
 
@@ -20826,7 +20826,7 @@ Kv 或 Db 实例
20826
20826
 
20827
20827
  > `protected` **\_writeBinary**(`data`): `boolean`
20828
20828
 
20829
- Defined in: [sys/ctr.ts:1045](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1045)
20829
+ Defined in: [sys/ctr.ts:1060](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1060)
20830
20830
 
20831
20831
  发送 socket 二进制
20832
20832
 
@@ -20848,7 +20848,7 @@ Defined in: [sys/ctr.ts:1045](https://github.com/maiyunnet/kebab/blob/master/sys
20848
20848
 
20849
20849
  > `protected` **\_writeResult**(`data`): `boolean`
20850
20850
 
20851
- Defined in: [sys/ctr.ts:1037](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1037)
20851
+ Defined in: [sys/ctr.ts:1052](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1052)
20852
20852
 
20853
20853
  发送结果对象文本
20854
20854
 
@@ -20870,7 +20870,7 @@ Defined in: [sys/ctr.ts:1037](https://github.com/maiyunnet/kebab/blob/master/sys
20870
20870
 
20871
20871
  > `protected` **\_writeText**(`data`): `boolean`
20872
20872
 
20873
- Defined in: [sys/ctr.ts:1029](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1029)
20873
+ Defined in: [sys/ctr.ts:1044](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1044)
20874
20874
 
20875
20875
  发送 socket 文本
20876
20876
 
@@ -20890,15 +20890,15 @@ Defined in: [sys/ctr.ts:1029](https://github.com/maiyunnet/kebab/blob/master/sys
20890
20890
 
20891
20891
  ### getAuthorization()
20892
20892
 
20893
- > **getAuthorization**(): `false` \| \{ `pwd`: `string`; `user`: `string`; \}
20893
+ > **getAuthorization**(): `false` \| \{ `pwd`: `string`; `type`: `"basic"`; `user`: `string`; \} \| \{ `token`: `string`; `type`: `"bearer"`; \}
20894
20894
 
20895
20895
  Defined in: [sys/ctr.ts:809](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L809)
20896
20896
 
20897
- 通过 header 或 _auth 获取 Basic Auth 鉴权信息
20897
+ 通过 header 或 _auth 获取鉴权信息,支持 Basic Auth 和 Bearer Token
20898
20898
 
20899
20899
  #### Returns
20900
20900
 
20901
- `false` \| \{ `pwd`: `string`; `user`: `string`; \}
20901
+ `false` \| \{ `pwd`: `string`; `type`: `"basic"`; `user`: `string`; \} \| \{ `token`: `string`; `type`: `"bearer"`; \}
20902
20902
 
20903
20903
  ***
20904
20904
 
@@ -23890,7 +23890,7 @@ sys/route/functions/getFormData.md
23890
23890
 
23891
23891
  > **getFormData**(`req`, `events?`, `limits?`): `Promise`\<`false` \| \{ `files`: `Record`\<`string`, [`IPostFile`](../../../index/interfaces/IPostFile.md) \| [`IPostFile`](../../../index/interfaces/IPostFile.md)[]\>; `post`: `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\>; \}\>
23892
23892
 
23893
- Defined in: [sys/route.ts:933](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L933)
23893
+ Defined in: [sys/route.ts:962](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L962)
23894
23894
 
23895
23895
  获取 formdata 的 post
23896
23896
 
@@ -23957,7 +23957,7 @@ sys/route/functions/getPost.md
23957
23957
 
23958
23958
  > **getPost**(`req`): `Promise`\<\{ `input`: `string`; `post`: `Record`\<`string`, `any`\>; `raw`: `Record`\<`string`, `any`\>; \}\>
23959
23959
 
23960
- Defined in: [sys/route.ts:866](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L866)
23960
+ Defined in: [sys/route.ts:876](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L876)
23961
23961
 
23962
23962
  获取 post 对象(通常已自动获取),如果是文件上传(formdata)的情况则不获取
23963
23963
 
@@ -24073,7 +24073,7 @@ sys/route/functions/unlinkUploadFiles.md
24073
24073
 
24074
24074
  > **unlinkUploadFiles**(`cctr`): `Promise`\<`void`\>
24075
24075
 
24076
- Defined in: [sys/route.ts:825](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L825)
24076
+ Defined in: [sys/route.ts:835](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L835)
24077
24077
 
24078
24078
  删除本次请求所有已上传的临时文件
24079
24079
 
@@ -24102,7 +24102,7 @@ sys/route/functions/waitCtr.md
24102
24102
 
24103
24103
  > **waitCtr**(`cctr`): `Promise`\<`void`\>
24104
24104
 
24105
- Defined in: [sys/route.ts:845](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L845)
24105
+ Defined in: [sys/route.ts:855](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L855)
24106
24106
 
24107
24107
  等待异步任务结束,并删除临时文件,如果结束后还有事务没关闭,则会在本函数中打印控制台并且写入 log 文件
24108
24108
  此时其实已经给客户端返回了,此处等待不消耗客户端的等待时间
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.1.0";
8
+ export declare const VER = "9.1.1";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.1.0';
9
+ export const VER = '9.1.1';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/session.js CHANGED
@@ -56,7 +56,12 @@ export class Session {
56
56
  }
57
57
  else if (auth) {
58
58
  const a = ctr.getAuthorization();
59
- if (a && typeof a !== 'string' && (a.user === 'token')) {
59
+ if (a && a.type === 'bearer') {
60
+ // --- Authorization: Bearer <token> ---
61
+ this._token = a.token;
62
+ }
63
+ else if (a && a.type === 'basic' && a.user === 'token') {
64
+ // --- Authorization: Basic base64(token:<token>),兼容旧模式 ---
60
65
  this._token = a.pwd;
61
66
  }
62
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.1.0",
3
+ "version": "9.1.1",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
package/sys/ctr.d.ts CHANGED
@@ -58,10 +58,10 @@ export declare class Ctr {
58
58
  'timeout': number;
59
59
  'callback': () => void;
60
60
  };
61
- /** --- 获取当前过期时间 --- */
61
+ /** --- 获取当前过期时间(毫秒) --- */
62
62
  get timeout(): number;
63
63
  /**
64
- * --- 设置当前过期时间 ---
64
+ * --- 设置当前过期时间(毫秒) ---
65
65
  */
66
66
  set timeout(num: number);
67
67
  /** --- 一些需要等待的事项的记录(异步任务、事务) --- */
@@ -231,14 +231,18 @@ export declare class Ctr {
231
231
  * --- 根据用户 ua 获取当前用户的设备类型 ---
232
232
  */
233
233
  protected _device(): 'android' | 'windows' | 'linux' | 'macintosh' | 'ipad' | 'unknown';
234
- /** --- auth 对象,user, pwd --- */
234
+ /** --- auth 对象 --- */
235
235
  private _authorization;
236
236
  /**
237
- * --- 通过 header 或 _auth 获取 Basic Auth 鉴权信息 ---
237
+ * --- 通过 header 或 _auth 获取鉴权信息,支持 Basic Auth Bearer Token ---
238
238
  */
239
239
  getAuthorization(): {
240
+ 'type': 'basic';
240
241
  'user': string;
241
242
  'pwd': string;
243
+ } | {
244
+ 'type': 'bearer';
245
+ 'token': string;
242
246
  } | false;
243
247
  /**
244
248
  * --- 获取 data 数据 ---
package/sys/ctr.js CHANGED
@@ -78,12 +78,12 @@ export class Ctr {
78
78
  }
79
79
  /** --- timeout 的 timer --- */
80
80
  _timer;
81
- /** --- 获取当前过期时间 --- */
81
+ /** --- 获取当前过期时间(毫秒) --- */
82
82
  get timeout() {
83
83
  return this._timer?.timeout ?? 30_000;
84
84
  }
85
85
  /**
86
- * --- 设置当前过期时间 ---
86
+ * --- 设置当前过期时间(毫秒) ---
87
87
  */
88
88
  set timeout(num) {
89
89
  if (!this._timer) {
@@ -642,10 +642,10 @@ export class Ctr {
642
642
  }
643
643
  return 'unknown';
644
644
  }
645
- /** --- auth 对象,user, pwd --- */
645
+ /** --- auth 对象 --- */
646
646
  _authorization = null;
647
647
  /**
648
- * --- 通过 header 或 _auth 获取 Basic Auth 鉴权信息 ---
648
+ * --- 通过 header 或 _auth 获取鉴权信息,支持 Basic Auth Bearer Token ---
649
649
  */
650
650
  getAuthorization() {
651
651
  if (this._authorization !== null) {
@@ -664,15 +664,28 @@ export class Ctr {
664
664
  if (typeof auth !== 'string') {
665
665
  return false;
666
666
  }
667
- let authArr = auth.split(' ');
668
- if (authArr[1] === undefined) {
667
+ const spaceIdx = auth.indexOf(' ');
668
+ if (spaceIdx === -1) {
669
669
  return false;
670
670
  }
671
- if (!(auth = lCrypto.base64Decode(authArr[1]))) {
671
+ const scheme = auth.slice(0, spaceIdx).toLowerCase();
672
+ const credential = auth.slice(spaceIdx + 1).trim();
673
+ if (!credential) {
672
674
  return false;
673
675
  }
674
- authArr = auth.split(':');
675
- this._authorization = { 'user': authArr[0], 'pwd': authArr[1] ?? '' };
676
+ if (scheme === 'bearer') {
677
+ this._authorization = { 'type': 'bearer', 'token': credential };
678
+ return this._authorization;
679
+ }
680
+ // --- Basic Auth: base64(user:pwd) ---
681
+ const decoded = lCrypto.base64Decode(credential);
682
+ if (!decoded) {
683
+ return false;
684
+ }
685
+ const colonIdx = decoded.indexOf(':');
686
+ const user = colonIdx === -1 ? decoded : decoded.slice(0, colonIdx);
687
+ const pwd = colonIdx === -1 ? '' : decoded.slice(colonIdx + 1);
688
+ this._authorization = { 'type': 'basic', 'user': user, 'pwd': pwd };
676
689
  return this._authorization;
677
690
  }
678
691
  /**
package/sys/route.js CHANGED
@@ -227,8 +227,18 @@ export async function run(data) {
227
227
  if (data.req.headers['cookie']) {
228
228
  const hcookies = data.req.headers['cookie'].split(';');
229
229
  for (const cookie of hcookies) {
230
- const co = cookie.split('=');
231
- cookies[co[0].trim()] = decodeURIComponent(co[1]);
230
+ const eqIndex = cookie.indexOf('=');
231
+ if (eqIndex === -1) {
232
+ continue;
233
+ }
234
+ const key = cookie.slice(0, eqIndex).trim();
235
+ const rawVal = cookie.slice(eqIndex + 1);
236
+ try {
237
+ cookies[key] = decodeURIComponent(rawVal);
238
+ }
239
+ catch {
240
+ cookies[key] = rawVal;
241
+ }
232
242
  }
233
243
  }
234
244
  // --- 处理 headers ---
@@ -818,11 +828,30 @@ export function getPost(req) {
818
828
  return;
819
829
  }
820
830
  // --- json 或普通 post ---
831
+ /** --- POST body 最大允许 50 MB,防止攻击者发送超大请求体耗尽内存 --- */
832
+ const maxPostSize = 50 * 1024 * 1024;
821
833
  let buffer = Buffer.from('');
834
+ let overflow = false;
822
835
  req.on('data', function (chunk) {
836
+ if (overflow) {
837
+ return;
838
+ }
839
+ if (buffer.length + chunk.length > maxPostSize) {
840
+ overflow = true;
841
+ buffer = Buffer.from('');
842
+ return;
843
+ }
823
844
  buffer = Buffer.concat([buffer, chunk], buffer.length + chunk.length);
824
845
  });
825
846
  req.on('end', function () {
847
+ if (overflow) {
848
+ resolve({
849
+ 'input': '',
850
+ 'raw': {},
851
+ 'post': {},
852
+ });
853
+ return;
854
+ }
826
855
  const s = buffer.toString();
827
856
  if (!s) {
828
857
  resolve({