* Get the content stream of the request. * * @param {Object} req * @param {Function} debug * @param {boolean} inflate * @returns {Object} * @private
(req, debug, inflate)
| 182 | * @private |
| 183 | */ |
| 184 | function contentstream (req, debug, inflate) { |
| 185 | const encoding = (req.headers['content-encoding'] || 'identity').toLowerCase() |
| 186 | const length = req.headers['content-length'] |
| 187 | |
| 188 | debug('content-encoding "%s"', encoding) |
| 189 | |
| 190 | if (inflate === false && encoding !== 'identity') { |
| 191 | throw createError(415, 'content encoding unsupported', { |
| 192 | encoding: encoding, |
| 193 | type: 'encoding.unsupported' |
| 194 | }) |
| 195 | } |
| 196 | |
| 197 | if (encoding === 'identity') { |
| 198 | req.length = length |
| 199 | return req |
| 200 | } |
| 201 | |
| 202 | const stream = createDecompressionStream(encoding, debug) |
| 203 | req.pipe(stream) |
| 204 | return stream |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Create a decompression stream for the given encoding. |
no test coverage detected
searching dependent graphs…