MCPcopy Index your code
hub / github.com/expressjs/body-parser / contentstream

Function contentstream

lib/read.js:184–205  ·  view source on GitHub ↗

* Get the content stream of the request. * * @param {Object} req * @param {Function} debug * @param {boolean} inflate * @returns {Object} * @private

(req, debug, inflate)

Source from the content-addressed store, hash-verified

182 * @private
183 */
184function 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.

Callers 1

readFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…