From 9ff92ebdbcf768951f4bdba335c111f542ed76db Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Tue, 1 Oct 2024 14:30:29 +0900 Subject: [PATCH] feat(streaming): add `Identity` as Content-Encoding for `streamText()` --- src/helper/streaming/text.test.ts | 1 + src/helper/streaming/text.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/helper/streaming/text.test.ts b/src/helper/streaming/text.test.ts index 9458a095..d4301506 100644 --- a/src/helper/streaming/text.test.ts +++ b/src/helper/streaming/text.test.ts @@ -20,6 +20,7 @@ describe('Text Streaming Helper', () => { expect(res.headers.get('content-type')).toMatch(/^text\/plain/) expect(res.headers.get('x-content-type-options')).toBe('nosniff') expect(res.headers.get('transfer-encoding')).toBe('chunked') + expect(res.headers.get('content-encoding')).toBe('identity') if (!res.body) { throw new Error('Body is null') diff --git a/src/helper/streaming/text.ts b/src/helper/streaming/text.ts index fe707cc6..0a573a39 100644 --- a/src/helper/streaming/text.ts +++ b/src/helper/streaming/text.ts @@ -11,5 +11,6 @@ export const streamText = ( c.header('Content-Type', TEXT_PLAIN) c.header('X-Content-Type-Options', 'nosniff') c.header('Transfer-Encoding', 'chunked') + c.header('Content-Encoding', 'identity') return stream(c, cb, onError) }