onProxyRes相关代码:
option.onProxyRes = function (proxyRes: any, req: any, res: any) {
// 参考:https://www.jianshu.com/p/f8ac6e813b96
const oriWriteHead = res.writeHead;
const oriWrite = res.write;
const oriEnd = res.end;
let chunks: any = [];
let size = 0;
Object.assign(res, {
writeHead: () => {
},
write: (chunk: any) => {
chunks.push(chunk);
size += chunk.length;
},
end: () => {
let oriBuffer = Buffer.concat(chunks, size);
console.log