summaryrefslogtreecommitdiff
path: root/cli/tests/unit/flash_test.ts
diff options
context:
space:
mode:
authorayame113 <40050810+ayame113@users.noreply.github.com>2022-10-05 15:51:59 +0900
committerGitHub <noreply@github.com>2022-10-05 12:21:59 +0530
commitb5425ae2d37d3dd123cbc0430785c0f61082e3e3 (patch)
tree8f972ed187b82873587409b42fc06fe718b81b93 /cli/tests/unit/flash_test.ts
parentb312503f8f9d7b289b28c2235bdaba1259fc3c37 (diff)
fix(ext/flash): Avoid sending Content-Length when status code is 204 (#15901)
Currently Content-Length is sent when the status code is 204. However, according to the spec, this should not be sent. Modify the if statement below to prevent the Content-Length from being sent.
Diffstat (limited to 'cli/tests/unit/flash_test.ts')
-rw-r--r--cli/tests/unit/flash_test.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts
index 48310296e..a5a31a136 100644
--- a/cli/tests/unit/flash_test.ts
+++ b/cli/tests/unit/flash_test.ts
@@ -1890,6 +1890,33 @@ Deno.test(
Deno.test(
{ permissions: { net: true } },
+ async function httpServer204ResponseDoesntSendContentLength() {
+ const listeningPromise = deferred();
+ const ac = new AbortController();
+ const server = Deno.serve({
+ handler: (_request) => new Response(null, { status: 204 }),
+ port: 4501,
+ signal: ac.signal,
+ onListen: onListen(listeningPromise),
+ onError: createOnErrorCb(ac),
+ });
+
+ try {
+ await listeningPromise;
+ const resp = await fetch("http://127.0.0.1:4501/", {
+ method: "GET",
+ headers: { "connection": "close" },
+ });
+ assertEquals(resp.headers.get("Content-Length"), null);
+ } finally {
+ ac.abort();
+ await server;
+ }
+ },
+);
+
+Deno.test(
+ { permissions: { net: true } },
async function httpServer304ResponseDoesntSendBody() {
const promise = deferred();
const ac = new AbortController();