@@ -7,12 +7,12 @@ const fp = require('fastify-plugin')
77const encodingNegotiator = require ( '@fastify/accept-negotiator' )
88const pump = require ( 'pump' )
99const mimedb = require ( 'mime-db' )
10- const intoStream = require ( 'into-stream' )
1110const peek = require ( 'peek-stream' )
1211const { Minipass } = require ( 'minipass' )
1312const pumpify = require ( 'pumpify' )
13+ const { Readable } = require ( 'readable-stream' )
1414
15- const { isStream, isGzip, isDeflate } = require ( './lib/utils' )
15+ const { isStream, isGzip, isDeflate, intoAsyncIterator } = require ( './lib/utils' )
1616
1717const InvalidRequestEncodingError = createError ( 'FST_CP_ERR_INVALID_CONTENT_ENCODING' , 'Unsupported Content-Encoding: %s' , 415 )
1818const InvalidRequestCompressedPayloadError = createError ( 'FST_CP_ERR_INVALID_CONTENT' , 'Could not decompress the request payload using the provided encoding' , 400 )
@@ -276,7 +276,7 @@ function buildRouteCompress (fastify, params, routeOptions, decorateOnly) {
276276 if ( Buffer . byteLength ( payload ) < params . threshold ) {
277277 return next ( )
278278 }
279- payload = intoStream ( payload )
279+ payload = Readable . from ( intoAsyncIterator ( payload ) )
280280 }
281281
282282 setVaryHeader ( reply )
@@ -400,7 +400,7 @@ function compress (params) {
400400 if ( Buffer . byteLength ( payload ) < params . threshold ) {
401401 return this . send ( payload )
402402 }
403- payload = intoStream ( payload )
403+ payload = Readable . from ( intoAsyncIterator ( payload ) )
404404 }
405405
406406 setVaryHeader ( this )
@@ -509,7 +509,7 @@ function maybeUnzip (payload, serialize) {
509509 // handle case where serialize doesn't return a string or Buffer
510510 if ( ! Buffer . isBuffer ( buf ) ) return result
511511 if ( isCompressed ( buf ) === 0 ) return result
512- return intoStream ( result )
512+ return Readable . from ( intoAsyncIterator ( result ) )
513513}
514514
515515function zipStream ( deflate , encoding ) {
0 commit comments