@@ -46,6 +46,18 @@ describe('Compress Middleware', () => {
4646 c . header ( 'Content-Length' , '1024' )
4747 return c . body ( new Uint8Array ( 1024 ) ) // Simulated compressed data
4848 } )
49+ app . get ( '/transfer-encoding-deflate' , ( c ) => {
50+ c . header ( 'Content-Type' , 'application/octet-stream' )
51+ c . header ( 'Transfer-Encoding' , 'deflate' )
52+ c . header ( 'Content-Length' , '1024' )
53+ return c . body ( new Uint8Array ( 1024 ) ) // Simulated deflate data
54+ } )
55+ app . get ( '/chunked' , ( c ) => {
56+ c . header ( 'Content-Type' , 'application/octet-stream' )
57+ c . header ( 'Transfer-Encoding' , 'chunked' )
58+ c . header ( 'Content-Length' , '1024' )
59+ return c . body ( new Uint8Array ( 1024 ) ) // Simulated chunked data
60+ } )
4961 app . get ( '/stream' , ( c ) =>
5062 stream ( c , async ( stream ) => {
5163 c . header ( 'Content-Type' , 'text/plain' )
@@ -133,6 +145,18 @@ describe('Compress Middleware', () => {
133145 const res = await testCompression ( '/jpeg-image' , 'gzip' , null )
134146 expect ( res . headers . get ( 'Content-Length' ) ) . toBeDefined ( )
135147 } )
148+
149+ it ( 'should not compress transfer-encoding: deflate' , async ( ) => {
150+ const res = await testCompression ( '/transfer-encoding-deflate' , 'gzip' , null )
151+ expect ( res . headers . get ( 'Content-Length' ) ) . toBe ( '1024' )
152+ expect ( res . headers . get ( 'Transfer-Encoding' ) ) . toBe ( 'deflate' )
153+ } )
154+
155+ it ( 'should not compress transfer-encoding: chunked' , async ( ) => {
156+ const res = await testCompression ( '/chunked' , 'gzip' , null )
157+ expect ( res . headers . get ( 'Content-Length' ) ) . toBe ( '1024' )
158+ expect ( res . headers . get ( 'Transfer-Encoding' ) ) . toBe ( 'chunked' )
159+ } )
136160 } )
137161
138162 describe ( 'JSON Handling' , ( ) => {
0 commit comments