MCPcopy Create free account
hub / github.com/expressjs/body-parser / createDecompressionStream

Function createDecompressionStream

lib/read.js:214–235  ·  view source on GitHub ↗

* Create a decompression stream for the given encoding. * @param {string} encoding * @param {Function} debug * @returns {Object} * @private

(encoding, debug)

Source from the content-addressed store, hash-verified

212 * @private
213 */
214function createDecompressionStream (encoding, debug) {
215 switch (encoding) {
216 case 'deflate':
217 debug('inflate body')
218 return zlib.createInflate()
219 case 'gzip':
220 debug('gunzip body')
221 return zlib.createGunzip()
222 case 'br':
223 debug('brotli decompress body')
224 return zlib.createBrotliDecompress()
225 case 'zstd':
226 if (hasZstandardSupport) {
227 debug('zstd decompress body')
228 return zlib.createZstdDecompress()
229 }
230 }
231 throw createError(415, 'unsupported content encoding "' + encoding + '"', {
232 encoding,
233 type: 'encoding.unsupported'
234 })
235}
236
237/**
238 * Dump the contents of a request.

Callers 1

readFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected