handle compressed
516580
function handleCompressed(res, _write, _end, unzip, zip, callback) {
  // The rewrite response method is replaced by unzip stream.
  res.write = data => unzip.write(data);

  res.end = () => unzip.end();

  // Concat the unzip stream.
  let concatWrite = concatStream(data => {
    let body;
    try {
      body = JSON.parse(data.toString());
    } catch (e) {
      body = data.toString();
      console.log('JSON.parse error:', e);
    }

    // Custom modified logic
    if (typeof callback === 'function') {
      body = callback(body);
    }

    let finish = _body => {
      // Converts the JSON to buffer.
      let body = new Buffer(JSON.stringify(_body));

      // Call the response method and recover the content-encoding.
      zip.on('data', chunk => _write.call(res, chunk));
      zip.on('end', () => _end.call(res));

      zip.write(body);
      zip.end();
    };

    if (body && body.then) {
      body.then(finish);
    } else {
      finish(body);
    }
  });

  unzip.pipe(concatWrite);
}
1135745
function canCompress(command) {
  const commandDoc = command instanceof Msg ? command.command : command.query;
  const commandName = Object.keys(commandDoc)[0];
  return uncompressibleCommands.indexOf(commandName) === -1;
}
490290
function afterHandleSrc (content) {

        content = content.replace(/#tidy1#/g, 'progid:');
        content = content.replace(/#tidy2#/g, '://');
        content = content.replace(/#tidy3#/g, ':');
        content = content.replace(/#tidy4#/g, ';');
        content = content.replace(/#tidy5#/g, '/');
        content = content.replace(/#tidy6#/g, '//');

        // handle compressive css file 
        content = content.replace(/(\}|\*\/)(?!\r|\n)/g, function(match){
            return match + '\n';
        });

        return content;
    }
615014
def compress_js(uncompressed)
      if options[:compressor] == 'yui'
        begin
          require "yui/compressor"
        rescue LoadError
          raise "You must install the yui compressor gem to use the compressor\ngem install yui-compressor"
        end
        compressor = ::YUI::JavaScriptCompressor.new
      else
        begin
          require 'closure-compiler'
        rescue LoadError
          raise "You must install the closure compiler gem to use the compressor\ngem install closure-compiler"
        end
        compressor = ::Closure::Compiler.new
      end
      begin
        compressor.compress(uncompressed)
      rescue Exception => e
        logger.error e.message
      end
    end
52605
public function compress()
    {
        if (!$this->collection->schema) {
            $this->compressed =& $this->data;

            return;
        }
        if ($this->state !== 'compressed' && $this->collection) {
            $this->compressed = $this->applyCompression($this->data);
            $this->asDotSyntax();
            $this->state = 'compressed';
        }
    }
960723
private void handleSnappyDecompression(final ChannelHandlerContext ctx, final FullBinaryMemcacheResponse response) {
        ByteBuf decompressed;
        if (response.content().readableBytes() > 0) {
            // we need to copy it on-heap...
            byte[] compressed = Unpooled.copiedBuffer(response.content()).array();
            try {
                decompressed = Unpooled.wrappedBuffer(Snappy.uncompress(compressed, 0, compressed.length));
            } catch (Exception ex) {
                throw new RuntimeException("Could not decode snappy-compressed value.", ex);
            }
        } else {
            decompressed = Unpooled.buffer(0);
        }


        response.content().release();
        response.setContent(decompressed);
        response.setTotalBodyLength(
            response.getExtrasLength()
                + response.getKeyLength()
                + decompressed.readableBytes()
        );
        response.setDataType((byte) (response.getDataType() & ~DATATYPE_SNAPPY));
    }
501813
def compress(func):
    
    @wraps(func)
    def wrapper(*args, **kwargs):
        result = func(*args, **kwargs)
        if ('gzip' in bottle.request.headers.get('Accept-Encoding', '') and
                isinstance(result, string_type) and
                len(result) > 1024):
            if isinstance(result, unicode):
                result = result.encode('utf-8')
            tmp_fo = BytesIO()
            with gzip.GzipFile(mode='wb', fileobj=tmp_fo) as gzip_fo:
                gzip_fo.write(result)
            result = tmp_fo.getvalue()
            bottle.response.add_header('Content-Encoding', 'gzip')
        return result
    return wrapper
1335872
def _query_uncompressed(options, collection_name, num_to_skip,
          num_to_return, query, field_selector, opts, check_keys=False):
    """"""
    op_query, max_bson_size = _query(
        options,
        collection_name,
        num_to_skip,
        num_to_return,
        query,
        field_selector,
        opts,
        check_keys)
    rid, msg = __pack_message(2004, op_query)
    return rid, msg, max_bson_size
193159
function Request__compress(response) {
        var accept = this.getRequestHeader('Accept-Encoding'),
            isForCompress = (Type.isString(response) || response instanceof Buffer) && !this.isCompressed,
            that = this;

        if (this.isRendered) {
            // we have multiple recursion in parse for catching
            return false;
        }


        if (isForCompress && !!this.isCompressionEnabled && Type.isString(accept)) {
            if (!this.hasHeader('Vary')) {
                this.addHeader('Vary', 'Accept-Encoding');
            }
            if (accept.indexOf('gzip') > -1) {
                return new Promise(function (resolve, reject) {
                    zlib.gzip(response, function (err, data) {
                        if (err) {
                            return reject(err);
                        }
                        that.isCompressed = true;
                        that.addHeader('Content-Encoding', 'gzip');
                        resolve(data);
                    });
                });
            } else if (accept.indexOf('deflate') > -1) {
                return new Promise(function (resolve, reject) {
                    zlib.deflate(response, function (err, data) {
                        if (err) {
                            return reject(err);
                        }
                        that.isCompressed = true;
                        that.addHeader('Content-Encoding', 'deflate');
                        resolve(data);
                    });
                });
            }
        }

        return response;
    }
1172952
def __decompressContent(coding, pgctnt):
    '''
    
    '''

    log.trace("Decompressing %s byte content with compression type: %s", len(pgctnt), coding)

    if coding == 'deflate':
        pgctnt = zlib.decompress(pgctnt, -zlib.MAX_WBITS)

    elif coding == 'gzip':
        buf = io.BytesIO(pgctnt)
        f = gzip.GzipFile(fileobj=buf)
        pgctnt = f.read()

    elif coding == "sdch":
        raise ValueError("SDCH compression is not currently supported")
    elif coding == "br":
        raise ValueError("Brotli compression is not currently supported")
    elif coding == "compress":
        raise ValueError("LZW compression is not currently supported")

    elif coding == 'identity':
        pass

    log.trace("Content size after decompression: %s", len(pgctnt))
    return pgctnt
1248691
def compress(func):
    """"""
    def wrapper(*args, **kwargs):
        """Wrapper that take one function and return the compressed result."""
        ret = func(*args, **kwargs)
        logger.debug('Receive {} {} request with header: {}'.format(
            request.method,
            request.url,
            ['{}: {}'.format(h, request.headers.get(h)) for h in request.headers.keys()]
        ))
        if 'deflate' in request.headers.get('Accept-Encoding', ''):
            response.headers['Content-Encoding'] = 'deflate'
            ret = deflate_compress(ret)
        else:
            response.headers['Content-Encoding'] = 'identity'
        return ret

    def deflate_compress(data, compress_level=6):
        """Compress given data using the DEFLATE algorithm"""
        # Init compression
        zobj = zlib.compressobj(compress_level,
                                zlib.DEFLATED,
                                zlib.MAX_WBITS,
                                zlib.DEF_MEM_LEVEL,
                                zlib.Z_DEFAULT_STRATEGY)

        # Return compressed object
        return zobj.compress(b(data)) + zobj.flush()

    return wrapper
178410
def _handlePressure(self, d):
        
        press = d['press']
        if press != '////':
            press = float(press.replace('O', '0'))
            if d['unit']:
                if d['unit'] == 'A' or (d['unit2'] and d['unit2'] == 'INS'):
                    self.press = CustomPressure(press / 100, 'IN')
                elif d['unit'] == 'SLP':
                    if press < 500:
                        press = press / 10 + 1000
                    else:
                        press = press / 10 + 900
                    self.press = CustomPressure(press)
                    self._remarks.append("sea-level pressure %.1fhPa" % press)
                else:
                    self.press = CustomPressure(press)
            elif press > 2500:
                self.press = CustomPressure(press / 100, 'IN')
            else:
                self.press = CustomPressure(press)
1010027
def compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None):
    
    comp = LZMACompressor(format, check, preset, filters)
    return comp.compress(data) + comp.flush()
257765
public function compress()
    {
        $this->archivePath = $this->compressedArchivePath . $this->buildArchiveFilename();

        $archive = $this->processor->getCompressionCommand($this->archivePath, $this->outputPath);

        $this->filesystem->mkdir($this->compressedArchivePath);
        $this->filesystem->mkdir($this->outputPath);
        $this->execute($archive);

        if ($this->splitter !== null) {
            $this->split();
        }
    }
1159784
def _compress_obj(obj, level):
    
    return zlib.compress(pickle.dumps(obj, protocol=2), level)
68940
public function decompress()
    {
        if ($this->state !== 'normal' && $this->collection) {
            $this->data = $this->applyDecompression($this->data);
            $this->state = 'normal';
        }
    }
36523
@Override
    public void close()
            throws IOException
    {
        compressed = null;
        uncompressed = null;
        if (in != null) {
            in.close();
        }
    }