File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -670,6 +670,21 @@ describe('node-fetch', () => {
670670 } )
671671 } )
672672
673+ it ( 'should decompress zstandard response' , function ( ) {
674+ if ( typeof zlib . createZstdDecompress !== 'function' ) {
675+ this . skip ( )
676+ }
677+
678+ const url = `${ base } zstandard`
679+ return fetch ( url ) . then ( res => {
680+ assert . strictEqual ( res . headers . get ( 'content-type' ) , 'text/plain' )
681+ return res . text ( ) . then ( result => {
682+ assert . strictEqual ( typeof result , 'string' )
683+ assert . strictEqual ( result , 'hello world' )
684+ } )
685+ } )
686+ } )
687+
673688 it ( 'should handle no content response with brotli encoding' , function ( ) {
674689 if ( typeof zlib . createBrotliDecompress !== 'function' ) {
675690 this . skip ( )
Original file line number Diff line number Diff line change @@ -164,6 +164,20 @@ module.exports = class TestServer {
164164 }
165165 }
166166
167+ if ( p === '/zstandard' ) {
168+ res . statusCode = 200
169+ res . setHeader ( 'Content-Type' , 'text/plain' )
170+ if ( typeof zlib . createZstdDecompress === 'function' ) {
171+ res . setHeader ( 'Content-Encoding' , 'zstd' )
172+ zlib . zstdCompress ( 'hello world' , ( err , buffer ) => {
173+ if ( err ) {
174+ throw err
175+ }
176+ res . end ( buffer )
177+ } )
178+ }
179+ }
180+
167181 if ( p === '/multiunsupported' ) {
168182 res . statusCode = 200
169183 res . setHeader ( 'Content-Type' , 'text/plain' )
You can’t perform that action at this time.
0 commit comments