chaneg deno code

This commit is contained in:
zizifn
2022-12-06 03:12:50 +08:00
committed by zizifn
parent ee1d43d8cf
commit 96c877f52f

View File

@@ -34,12 +34,19 @@ ${userID ? 'has UUID env' : 'no UUID env'}
hostname: serverAddress, 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 // 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. // and casue deno can't get TCP pcakge.
// 2. current soluction for this, let proxy client wait for few ms and then end readablestream // 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 // 3. this is only inpact HTTP proxy not https
const proxyResp = request.body?.pipeThrough(connection); (async () => {
return new Response(proxyResp, { for await (let chunk of request.body || []) {
// console.log(new TextDecoder().decode(chunk));
connection.write(chunk);
}
})();
return new Response(connection.readable, {
status: 200, status: 200,
headers: {}, headers: {},
}); });