lib/camp.js
function getCompressedStream(req, res) {
  var encoding = req.headers['accept-encoding'] || '';
  var stream;
  var contentEncodingHeader = res.getHeader('Content-Encoding');
  if ((contentEncodingHeader === 'gzip') || /\bgzip\b/.test(encoding)) {
    if (!contentEncodingHeader) {
      res.setHeader('Content-Encoding', 'gzip');
    }
    stream = zlib.createGzip();
    stream.pipe(res);
  } else if ((contentEncodingHeader === 'deflate') ||
      /\bdeflate\b/.test(encoding)) {
    if (!contentEncodingHeader) {
      res.setHeader('Content-Encoding', 'deflate');
    }
    stream = zlib.createDeflate();
    stream.pipe(res);
  }
  return stream;
}
function getCompressedStream(req, res) {
  var encoding = req.headers['accept-encoding'] || '';
  var stream;
  var contentEncodingHeader = res.getHeader('Content-Encoding');
  if ((contentEncodingHeader === 'gzip') || /\bgzip\b/.test(encoding)) {
    if (!contentEncodingHeader) {
      res.setHeader('Content-Encoding', 'gzip');
    }
    stream = zlib.createGzip();
    stream.pipe(res);
  } else if ((contentEncodingHeader === 'deflate') ||
      /\bdeflate\b/.test(encoding)) {
    if (!contentEncodingHeader) {
      res.setHeader('Content-Encoding', 'deflate');
    }
    stream = zlib.createDeflate();
    stream.pipe(res);
  }
  return stream;
}
function getCompressedStream ( req , res ) { var encoding = req . headers [ 'accept-encoding' ] || '' ; var stream ; var contentEncodingHeader = res . getHeader ( 'Content-Encoding' ) ; if ( ( contentEncodingHeader === 'gzip' ) || / \bgzip\b / . test ( encoding ) ) { if ( ! contentEncodingHeader ) { res . setHeader ( 'Content-Encoding' , 'gzip' ) ; } stream = zlib . createGzip ( ) ; stream . pipe ( res ) ; } else if ( ( contentEncodingHeader === 'deflate' ) || / \bdeflate\b / . test ( encoding ) ) { if ( ! contentEncodingHeader ) { res . setHeader ( 'Content-Encoding' , 'deflate' ) ; } stream = zlib . createDeflate ( ) ; stream . pipe ( res ) ; } return stream ; }
Return a writable response stream, using compression when possible.
Return a writable response stream using compression when possible .