@maiyunnet/kebab 8.5.1 → 8.5.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/doc/kebab-rag.md CHANGED
@@ -1410,7 +1410,7 @@ index/variables/VER.md
1410
1410
 
1411
1411
  # Variable: VER
1412
1412
 
1413
- > `const` **VER**: `"8.5.1"` = `'8.5.1'`
1413
+ > `const` **VER**: `"8.5.2"` = `'8.5.2'`
1414
1414
 
1415
1415
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1416
1416
 
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "8.5.1";
8
+ export declare const VER = "8.5.2";
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 = '8.5.1';
9
+ export const VER = '8.5.2';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "8.5.1",
3
+ "version": "8.5.2",
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/child.js CHANGED
@@ -118,9 +118,8 @@ async function run() {
118
118
  const host = (req.headers[':authority'] ?? req.headers['host'] ?? '');
119
119
  if (!host) {
120
120
  lCore.writeHead(res, 403);
121
- res.end('403 Forbidden', () => {
122
- req.socket.destroy();
123
- });
121
+ // --- 不能用 req.socket.destroy() 可能会导致底层复用(如 CDN) 的连接被直接断开 ---
122
+ res.end('403 Forbidden');
124
123
  return;
125
124
  }
126
125
  wrapWithLinkCount(host + req.url, () => requestHandler(req, res, true), '[CHILD][http2][request]', req.method ?? 'GET');
@@ -139,14 +138,17 @@ async function run() {
139
138
  if (!host) {
140
139
  res.setHeader('x-kebab-error', '0');
141
140
  lCore.writeHead(res, 403);
142
- res.end('403 Forbidden', () => {
143
- req.socket.destroy();
144
- });
141
+ // --- 不能用 req.socket.destroy() 可能会导致底层复用(如 CDN) 的连接被直接断开 ---
142
+ res.end('403 Forbidden');
145
143
  return;
146
144
  }
147
145
  wrapWithLinkCount(host + (req.url ?? ''), () => requestHandler(req, res, false), '[CHILD][http][request]', req.method ?? 'GET');
148
146
  }).on('clientError', (err, socket) => {
149
- socket.destroy();
147
+ // --- 不能用 socket.destroy() 可能会导致底层复用(如 CDN) 的连接被直接断开 ---
148
+ if (err.code === 'ECONNRESET' || !socket.writable) {
149
+ return;
150
+ }
151
+ socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
150
152
  }).on('upgrade', function (req, socket, head) {
151
153
  const host = (req.headers['host'] ?? '');
152
154
  if (!host) {
@@ -210,9 +212,8 @@ async function requestHandler(req, res, https) {
210
212
  if (!vhost) {
211
213
  res.setHeader('x-kebab-error', '1');
212
214
  lCore.writeHead(res, 403);
213
- res.end('403 Forbidden', () => {
214
- req.socket.destroy();
215
- });
215
+ // --- 不能用 req.socket.destroy() 可能会导致底层复用(如 CDN) 的连接被直接断开 ---
216
+ res.end('403 Forbidden');
216
217
  return;
217
218
  /*
218
219
  const text = '<h1>Kebab: No permissions</h1>host: ' + (req.headers[':authority'] as string | undefined ?? req.headers['host'] ?? '') + '<br>url: ' + (lText.htmlescape(req.url ?? ''));