diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts index 98249385bb..9ed0276a62 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(); diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js index 34b158e40d..5152fd9e5f 100644 --- a/ext/flash/01_http.js +++ b/ext/flash/01_http.js @@ -316,11 +316,13 @@ async function handleResponse( respBody, length, ); + // A HEAD request always ignores body, but includes the correct content-length size. + const responseLen = method === 1 ? core.byteLength(responseStr) : length; writeFixedResponse( serverId, i, responseStr, - length, + responseLen, !ws, // Don't close socket if there is a deferred websocket upgrade. respondFast, );