From 03be62cfe6a434a158349b8fc4bf2146c07b98be Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sun, 21 Dec 2025 14:19:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E5=91=BD=E5=90=8D=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E5=93=8D=E5=BA=94=E6=B5=81=E4=BC=A0=E8=BE=93=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=A2=9E=E5=BC=BA=E4=BB=A3=E7=A0=81=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assistant/src/module/assistant/proxy/http-proxy.ts | 4 ++-- assistant/src/module/assistant/proxy/pipe.ts | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/assistant/src/module/assistant/proxy/http-proxy.ts b/assistant/src/module/assistant/proxy/http-proxy.ts index 1669175..747ccf2 100644 --- a/assistant/src/module/assistant/proxy/http-proxy.ts +++ b/assistant/src/module/assistant/proxy/http-proxy.ts @@ -2,7 +2,7 @@ import http from 'node:http'; import https from 'node:https'; import { rewriteCookieDomain } from '../https/cookie-rewrite.ts'; import { ProxyInfo } from './proxy.ts'; -import { pipeProxyReq, pipeIncoming, pipeStream } from './pipe.ts'; +import { pipeProxyReq, pipeProxyRes, pipeStream } from './pipe.ts'; export const defaultApiProxy = [ { path: '/api/router', @@ -105,7 +105,7 @@ export const httpProxy = (req: http.IncomingMessage, res: http.ServerResponse, p res.writeHead(proxyRes.statusCode, responseHeaders); // 将代理响应流写入客户端响应 // proxyRes.pipe(res, { end: true }); - pipeIncoming(proxyRes, res); + pipeProxyRes(proxyRes, res); }); // 处理代理请求的错误事件 proxyReq.on('error', (err) => { diff --git a/assistant/src/module/assistant/proxy/pipe.ts b/assistant/src/module/assistant/proxy/pipe.ts index 89d7011..d52344c 100644 --- a/assistant/src/module/assistant/proxy/pipe.ts +++ b/assistant/src/module/assistant/proxy/pipe.ts @@ -42,7 +42,7 @@ export const pipeStream = (readStream: fs.ReadStream, res: http.ServerResponse) * @param proxyRes 代理服务器的响应对象 * @param res HTTP服务器响应对象 */ -export const pipeIncoming = (proxyRes: http.IncomingMessage, res: http.ServerResponse) => { +export const pipeProxyRes = (proxyRes: http.IncomingMessage, res: http.ServerResponse) => { if (isBun) { // Bun环境下需要手动收集数据并end,因为Bun的pipe机制与Node.js不同 const chunks: Buffer[] = []; @@ -81,8 +81,6 @@ export const pipeIncoming = (proxyRes: http.IncomingMessage, res: http.ServerRes export const pipeProxyReq = async (req: http.IncomingMessage, proxyReq: http.ClientRequest, res: any) => { if (isBun) { try { - const method = req.method?.toUpperCase(); - console.log('Bun pipeProxyReq method', method, req.body); // @ts-ignore const bunRequest = req.bun.request; const contentType = req.headers['content-type'] || '';