'Decompress the HTTP response and send it to the next handler.'

def http_response(self, request, response):

    if isinstance(response, SQLCachedResponse):
        return response
    enc_hdrs = response.info().getheaders('Content-encoding')
    for enc_hdr in enc_hdrs:
        try:
            if (('gzip' in enc_hdr) or ('compress' in enc_hdr)):
                body = response.read()
                data = gzip.GzipFile(fileobj=StringIO(body)).read()
            elif ('deflate' in enc_hdr):
                body = response.read()
                data = zlib.decompress(body)
            else:
                data = response.read()
        except:
            return response
        else:
            response.set_body(data)
            return response
    return response
