Example #1
0
 def _decompress(cls, data):
     """Decompress connection response.
     @return: decompressed data <type 'str'>"""
     encoding = cls.resp.getheader('Content-Encoding')
     if encoding == 'gzip':
         data = _zdecompress(data, _MAX_WBITS + 16)
     elif encoding == 'deflate':
         data = _zdecompress(data, -_MAX_WBITS)
     # else: failback to 'identity' encoding
     return data
Example #2
0
    def _decompress(cls, data):
        """Decompress a connection response.
        @return: decompressed data <type 'str'>"""

        encoding = cls.resp.getheader('Content-Encoding')

        if encoding == 'gzip':
            data = _zdecompress(data, _MAX_WBITS+16)
        elif encoding == 'deflate':
            data = _zdecompress(data, -_MAX_WBITS)
        # else/failback: the 'identity' encoding
        return data
Example #3
0
 def _decompress(self, data):
     """Decompress connection response.
     @return: decompressed data <type 'str'>"""
     #encoding = cls.resp.getheader('Content-Encoding')
     if 'content-encoding' not in dict(self.res.info()):
         return data
     encoding = dict(self.res.info())['content-encoding']
     if encoding == 'gzip':
         data = _zdecompress(data, _MAX_WBITS + 16)
     elif encoding == 'deflate':
         data = _zdecompress(data, -_MAX_WBITS)
     # else/failback: the 'identity' encoding
     return data