From 777468f5a39a615e3fe00f7fab16df23114d1f03 Mon Sep 17 00:00:00 2001 From: RobinzZH Date: Fri, 11 Apr 2025 13:19:04 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix(incoming):=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=AD=98=E9=87=8F=E7=BC=93=E5=86=B2=E5=86=85=E5=AE=B9=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runtime/capture/__test__/incoming.test.ts | 1 + lib/core/runtime/capture/incoming.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/core/runtime/capture/__test__/incoming.test.ts b/lib/core/runtime/capture/__test__/incoming.test.ts index 2eca6b0a..134e0168 100644 --- a/lib/core/runtime/capture/__test__/incoming.test.ts +++ b/lib/core/runtime/capture/__test__/incoming.test.ts @@ -46,6 +46,7 @@ describe("capture response function test", () => { path: "/", method: "POST", headers: { + Connection: "Close", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": Buffer.byteLength(data) } diff --git a/lib/core/runtime/capture/incoming.ts b/lib/core/runtime/capture/incoming.ts index fb153ea3..79d3c153 100644 --- a/lib/core/runtime/capture/incoming.ts +++ b/lib/core/runtime/capture/incoming.ts @@ -45,10 +45,17 @@ export const captureReadableStream = ( info.bodyTooLarge = info.bodyLength > maxBodySize; }; - let { head } = (stream as any).readableBuffer; - while (head) { - handler(head.data); - head = head.next; + const rb = (stream as any).readableBuffer; + let { head } = rb; + if (head !== undefined) { + while (head) { + handler(head.data); + head = head.next; + } + } else if (rb.forEach) { + rb.forEach((c) => { + handler(c); + }); } (stream as any).push = (chunk: any, encoding?: string): boolean => { From 3985159d9a1d2c7c18bf701c2453a95ae9de4a11 Mon Sep 17 00:00:00 2001 From: RobinzZH Date: Fri, 11 Apr 2025 14:32:22 +0000 Subject: [PATCH 2/2] =?UTF-8?q?fix(index):=20=E6=B5=8B=E8=AF=95=E5=AE=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=B8=85=E7=90=86hack=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/__test__/index.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/__test__/index.test.ts b/lib/__test__/index.test.ts index 0ec5352a..a6840ef2 100644 --- a/lib/__test__/index.test.ts +++ b/lib/__test__/index.test.ts @@ -26,6 +26,7 @@ beforeAll(() => { afterAll(() => { server.close(); + uninstallHacks(); }); describe("tsw index", () => {