summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit/flash_test.ts27
-rw-r--r--ext/flash/01_http.js3
2 files changed, 29 insertions, 1 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();
diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js
index 789979ff9..17f99ca98 100644
--- a/ext/flash/01_http.js
+++ b/ext/flash/01_http.js
@@ -152,7 +152,8 @@
}
// MUST NOT send Content-Length or Transfer-Encoding if status code is 1xx or 204.
- if (status == 204 && status <= 100) {
+ if (status === 204 || status < 200) {
+ str += "\r\n";
return str;
}