summaryrefslogtreecommitdiff
path: root/cli/tests/unit/flash_test.ts
diff options
context:
space:
mode:
authorKamil Ogórek <kamil.ogorek@gmail.com>2023-02-12 11:43:05 +0100
committerGitHub <noreply@github.com>2023-02-12 16:13:05 +0530
commitd4e5a295f2f9af1f815596656a185b11d7dabb29 (patch)
tree79bccb5401460ca84ea55bef9cc1348c956b5d4e /cli/tests/unit/flash_test.ts
parentbbcb144a6d8360a5ff0878d738d151bad9a948e7 (diff)
fix(ext/flash): Always send correct number of bytes when handling HEAD requests (#17740)
This was not caught in the previous test case, as the response body was smaller than the size of `HEAD` response. This made `nwritten < responseLen` check in `writeFixedResponse` to fail, and not trigger `op_flash_respond_async` as a result. When the response body is larger than the `HEAD` though, as in the updated test case (`HEAD` i 120 bytes, where our response is 300 bytes), it would think that we still have something to send, and effectively panic, as `op_flash_respond` already removed the request from the pool. This change, makes the `handleResponse` function always calculate the number of bytes to transmit when `HEAD` request is encountered. Effectively ignoring `Content-Length` of the body, but still setting it correctly in the request header itself. Fixes https://github.com/denoland/deno/issues/17737
Diffstat (limited to 'cli/tests/unit/flash_test.ts')
-rw-r--r--cli/tests/unit/flash_test.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts
index 98249385b..9ed0276a6 100644
--- a/cli/tests/unit/flash_test.ts
+++ b/cli/tests/unit/flash_test.ts
@@ -1701,7 +1701,7 @@ Deno.test(
const server = Deno.serve({
handler: () => {
promise.resolve();
- return new Response("foo bar baz");
+ return new Response("NaN".repeat(100));
},
port: 4503,
signal: ac.signal,
@@ -1726,7 +1726,7 @@ Deno.test(
assert(readResult);
const msg = decoder.decode(buf.subarray(0, readResult));
- assert(msg.endsWith("Content-Length: 11\r\n\r\n"));
+ assert(msg.endsWith("Content-Length: 300\r\n\r\n"));
conn.close();