diff options
author | Rano | Ranadeep <ranadip.bswas@gmail.com> | 2024-07-15 13:40:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-15 17:10:59 +0530 |
commit | 702f7ee89c882f82b2fb649212bd8dbbb4476062 (patch) | |
tree | 95dbfcaebbd13fd614730da656d1dc49524c0fcc /tests/unit_node/http2_test.ts | |
parent | 9128cc98504676a9142869743d6ab1dc319da2ce (diff) |
fix(std/http2): release window capacity back to remote stream (#24576)
This PR adds logic to release window capacity after reading the chunks
from the stream. Without it, large response (more than `u16::MAX`) may
fill up the capacity and the whole response can't be read.
Closes https://github.com/denoland/deno/issues/24552
Closes https://github.com/denoland/deno/issues/24305
Diffstat (limited to 'tests/unit_node/http2_test.ts')
-rw-r--r-- | tests/unit_node/http2_test.ts | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/unit_node/http2_test.ts b/tests/unit_node/http2_test.ts index f2604b344..968ef15a0 100644 --- a/tests/unit_node/http2_test.ts +++ b/tests/unit_node/http2_test.ts @@ -203,3 +203,43 @@ Deno.test("[node/http2 client] write image buffer on request stream works", asyn await endPromise.promise; assertEquals(receivedData!, buffer); }); + +Deno.test("[node/http2 client] write 512kb buffer on request stream works", async () => { + const url = "https://localhost:5545"; + const client = http2.connect(url); + client.on("error", (err) => console.error(err)); + + const filePath = join( + import.meta.dirname!, + "testdata", + "lorem_ipsum_512kb.txt", + ); + const buffer = await readFile(filePath); + const req = client.request({ ":method": "POST", ":path": "/echo_server" }); + req.write(buffer, (err) => { + if (err) throw err; + }); + + let receivedData: Buffer; + req.on("data", (chunk) => { + if (!receivedData) { + receivedData = chunk; + } else { + receivedData = Buffer.concat([receivedData, chunk]); + } + }); + req.end(); + + const endPromise = Promise.withResolvers<void>(); + setTimeout(() => { + try { + client.close(); + } catch (_) { + // pass + } + endPromise.resolve(); + }, 2000); + + await endPromise.promise; + assertEquals(receivedData!, buffer); +}); |