四好公路
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
637 B

var zlib = require('zlib')
module.exports = inflate
function inflate(stream, options) {
if (!stream) {
throw new TypeError('argument stream is required')
}
options = options || {}
var encoding = options.encoding
|| (stream.headers && stream.headers['content-encoding'])
|| 'identity'
switch (encoding) {
case 'gzip':
case 'deflate':
break
case 'identity':
return stream
default:
var err = new Error('Unsupported Content-Encoding: ' + encoding)
err.status = 415
throw err
}
// no not pass-through encoding
delete options.encoding
return stream.pipe(zlib.Unzip(options))
}