From 96c877f52f50edddbc1a36b0e3e06e6f931eca92 Mon Sep 17 00:00:00 2001 From: zizifn <1803942+zizifn@users.noreply.github.com> Date: Tue, 6 Dec 2022 03:12:50 +0800 Subject: [PATCH] chaneg deno code --- apps/deno-bypass/src/bypass.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/deno-bypass/src/bypass.ts b/apps/deno-bypass/src/bypass.ts index 0bd9068..6b0e523 100644 --- a/apps/deno-bypass/src/bypass.ts +++ b/apps/deno-bypass/src/bypass.ts @@ -34,12 +34,19 @@ ${userID ? 'has UUID env' : 'no UUID env'} hostname: serverAddress, }); + // const proxyResp = request.body?.pipeThrough(connection); // 1. request.body readablestream end casue socket to be end, this will casue socket send FIN package early // and casue deno can't get TCP pcakge. // 2. current soluction for this, let proxy client wait for few ms and then end readablestream // 3. this is only inpact HTTP proxy not https - const proxyResp = request.body?.pipeThrough(connection); - return new Response(proxyResp, { + (async () => { + for await (let chunk of request.body || []) { + // console.log(new TextDecoder().decode(chunk)); + connection.write(chunk); + } + })(); + + return new Response(connection.readable, { status: 200, headers: {}, });