summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorIsaiah Gamble <77396670+tsar-boomba@users.noreply.github.com>2023-01-14 23:08:34 -0500
committerGitHub <noreply@github.com>2023-01-15 05:08:34 +0100
commitefcbfd5206fcdfac55c26a7133c04dd330d047b9 (patch)
treed34f0cccd2ffc0cde77e6bcdbc6fa8cf5f64f9b8 /cli
parentfd85f840cd707c31d08fa836562127e249c9ff62 (diff)
fix(ext/fetch) Fix request clone error in flash server (#16174)
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit/flash_test.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts
index 5604f6b5f..706b9f72b 100644
--- a/cli/tests/unit/flash_test.ts
+++ b/cli/tests/unit/flash_test.ts
@@ -2328,6 +2328,45 @@ Deno.test(
},
);
+// https://github.com/denoland/deno/issues/15858
+Deno.test(
+ { permissions: { net: true } },
+ async function httpServerCanCloneRequest() {
+ const ac = new AbortController();
+ const listeningPromise = deferred();
+
+ const server = Deno.serve({
+ handler: async (req) => {
+ const cloned = req.clone();
+ assertEquals(req.headers, cloned.headers);
+
+ // both requests can read body
+ await req.text();
+ await cloned.json();
+
+ return new Response("ok");
+ },
+ signal: ac.signal,
+ onListen: onListen(listeningPromise),
+ onError: createOnErrorCb(ac),
+ });
+
+ try {
+ await listeningPromise;
+ const resp = await fetch("http://localhost:9000/", {
+ headers: { connection: "close" },
+ method: "POST",
+ body: '{"sus":true}',
+ });
+ const text = await resp.text();
+ assertEquals(text, "ok");
+ } finally {
+ ac.abort();
+ await server;
+ }
+ },
+);
+
// Checks large streaming response
// https://github.com/denoland/deno/issues/16567
Deno.test(