demo/body-parser/lib/read.js
function contentstream (req, debug, inflate) {
  var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
  var length = req.headers['content-length']
  var stream

  debug('content-encoding "%s"', encoding)

  if (inflate === false && encoding !== 'identity') {
    throw createError(415, 'content encoding unsupported')
  }

  switch (encoding) {
    case 'deflate':
      stream = zlib.createInflate()
      debug('inflate body')
      req.pipe(stream)
      break
    case 'gzip':
      stream = zlib.createGunzip()
      debug('gunzip body')
      req.pipe(stream)
      break
    case 'identity':
      stream = req
      stream.length = length
      break
    default:
      throw createError(415, 'unsupported content encoding "' + encoding + '"', {
        encoding: encoding
      })
  }

  return stream
}
function contentstream (req, debug, inflate) {
  var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
  var length = req.headers['content-length']
  var stream

  debug('content-encoding "%s"', encoding)

  if (inflate === false && encoding !== 'identity') {
    throw createError(415, 'content encoding unsupported')
  }

  switch (encoding) {
    case 'deflate':
      stream = zlib.createInflate()
      debug('inflate body')
      req.pipe(stream)
      break
    case 'gzip':
      stream = zlib.createGunzip()
      debug('gunzip body')
      req.pipe(stream)
      break
    case 'identity':
      stream = req
      stream.length = length
      break
    default:
      throw createError(415, 'unsupported content encoding "' + encoding + '"', {
        encoding: encoding
      })
  }

  return stream
}
function contentstream ( req , debug , inflate ) { var encoding = ( req . headers [ 'content-encoding' ] || 'identity' ) . toLowerCase ( ) var length = req . headers [ 'content-length' ] var stream debug ( 'content-encoding "%s"' , encoding ) if ( inflate === false && encoding !== 'identity' ) { throw createError ( 415 , 'content encoding unsupported' ) } switch ( encoding ) { case 'deflate' : stream = zlib . createInflate ( ) debug ( 'inflate body' ) req . pipe ( stream ) break case 'gzip' : stream = zlib . createGunzip ( ) debug ( 'gunzip body' ) req . pipe ( stream ) break case 'identity' : stream = req stream . length = length break default : throw createError ( 415 , 'unsupported content encoding "' + encoding + '"' , { encoding : encoding } ) } return stream }
Get the content stream of the request.

@param {object} req
@param {function} debug
@param {boolean} [inflate=true]
@return {object}
@api private
Get the content stream of the request .