@maiyunnet/kebab 9.11.9 → 9.12.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/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/undici.js +16 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.
|
|
9
|
+
export const VER = '9.12.0';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/undici.js
CHANGED
|
@@ -6,6 +6,7 @@ import * as lText from '#kebab/lib/text.js';
|
|
|
6
6
|
import * as lCrypto from '#kebab/lib/crypto.js';
|
|
7
7
|
import * as lCore from '#kebab/lib/core.js';
|
|
8
8
|
import * as lCookie from '#kebab/lib/cookie.js';
|
|
9
|
+
import * as lZlib from '#kebab/lib/zlib.js';
|
|
9
10
|
// --- 自己 ---
|
|
10
11
|
import * as lFd from './undici/formdata.js';
|
|
11
12
|
import * as lRequest from './undici/request.js';
|
|
@@ -620,11 +621,23 @@ export async function rproxy(ctr, route, opt = {}) {
|
|
|
620
621
|
if (rres.headers) {
|
|
621
622
|
filterHeaders(rres.headers, res, opt.filter);
|
|
622
623
|
}
|
|
624
|
+
/** --- 当前的压缩对象 --- */
|
|
625
|
+
const compress = lZlib.createCompress(req.headers['accept-encoding'] ?? '');
|
|
626
|
+
if (compress) {
|
|
627
|
+
res.setHeader('content-encoding', compress.type);
|
|
628
|
+
}
|
|
623
629
|
lCore.writeHead(res, rres.headers?.['http-code'] ?? 200);
|
|
624
630
|
await new Promise((resolve) => {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
631
|
+
if (compress) {
|
|
632
|
+
stream.pipe(compress.compress).pipe(res).on('finish', () => {
|
|
633
|
+
resolve();
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
stream.pipe(res).on('finish', () => {
|
|
638
|
+
resolve();
|
|
639
|
+
});
|
|
640
|
+
}
|
|
628
641
|
});
|
|
629
642
|
return true;
|
|
630
643
|
}
|