From 39600c4449ad0835014730f577c6ebb2721e1a4c Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Sun, 8 Sep 2024 15:50:54 +0900 Subject: [PATCH] feat(jsx-renderer): set `Content-Encoding` when `stream` is `true` (#3355) --- src/middleware/jsx-renderer/index.test.tsx | 1 + src/middleware/jsx-renderer/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/middleware/jsx-renderer/index.test.tsx b/src/middleware/jsx-renderer/index.test.tsx index 17f97999..042a1b63 100644 --- a/src/middleware/jsx-renderer/index.test.tsx +++ b/src/middleware/jsx-renderer/index.test.tsx @@ -238,6 +238,7 @@ describe('JSX renderer', () => { expect(res.status).toBe(200) expect(res.headers.get('Transfer-Encoding')).toEqual('chunked') expect(res.headers.get('Content-Type')).toEqual('text/html; charset=UTF-8') + expect(res.headers.get('Content-Encoding')).toEqual('Identity') if (!res.body) { throw new Error('Body is null') diff --git a/src/middleware/jsx-renderer/index.ts b/src/middleware/jsx-renderer/index.ts index 4eee20f6..195a0229 100644 --- a/src/middleware/jsx-renderer/index.ts +++ b/src/middleware/jsx-renderer/index.ts @@ -60,6 +60,7 @@ const createRenderer = if (options.stream === true) { c.header('Transfer-Encoding', 'chunked') c.header('Content-Type', 'text/html; charset=UTF-8') + c.header('Content-Encoding', 'Identity') } else { for (const [key, value] of Object.entries(options.stream)) { c.header(key, value)