whistle.pastekitlab 1.9.2 → 1.9.4
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.js +4 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -44,6 +44,7 @@ function bufferToString(buffer) {
|
|
|
44
44
|
if (/[\uFFFD]/.test(result)) return null; // 检查是否有替换字符
|
|
45
45
|
return result;
|
|
46
46
|
} catch {
|
|
47
|
+
console.error('[pastekitlab]', 'bufferToString error:', e);
|
|
47
48
|
return null;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -332,7 +333,7 @@ module.exports = (server, options) => {
|
|
|
332
333
|
url,
|
|
333
334
|
method: req.method,
|
|
334
335
|
requestHeaders: {...req.headers},
|
|
335
|
-
body:
|
|
336
|
+
body: bufferToString(Buffer.from(reqBody)),
|
|
336
337
|
bodyBase64: Buffer.from(reqBody).toString('base64'),
|
|
337
338
|
timestamp: Date.now()
|
|
338
339
|
};
|
|
@@ -390,16 +391,11 @@ module.exports = (server, options) => {
|
|
|
390
391
|
// 直接 pipe 流到响应
|
|
391
392
|
proxyRes.pipe(res);
|
|
392
393
|
|
|
393
|
-
// 收集响应数据用于 WebSocket
|
|
394
|
+
// 收集响应数据用于 WebSocket 通知
|
|
394
395
|
let responseDataBuffer = Buffer.alloc(0);
|
|
395
396
|
|
|
396
397
|
proxyRes.on('data', (chunk) => {
|
|
397
|
-
|
|
398
|
-
if (responseDataBuffer.length < 1024 * 1024) {
|
|
399
|
-
const remaining = 1024 * 1024 - responseDataBuffer.length;
|
|
400
|
-
const toCollect = chunk.slice(0, remaining);
|
|
401
|
-
responseDataBuffer = Buffer.concat([responseDataBuffer, toCollect]);
|
|
402
|
-
}
|
|
398
|
+
responseDataBuffer = Buffer.concat([responseDataBuffer, chunk]);
|
|
403
399
|
});
|
|
404
400
|
|
|
405
401
|
proxyRes.on('end', () => {
|
package/package.json
CHANGED