def request(self, next, request):
        resp = next()
        # TODO: shortcut redirects/304s/responses without content?
        resp.vary.add('Accept-Encoding')
        if resp.content_encoding or not request.accept_encodings['gzip']:
            return resp

        if 'msie' in request.user_agent.browser:
            if not (resp.content_type.startswith('text/') or
                    resp.content_type in 'javascript'):
                return resp

        if resp.is_streamed:
            return resp  # TODO
        else:
            comp_content = compress(resp.data, self.compress_level)
            if len(comp_content) >= len(resp.data):
                return resp
            resp.response = [comp_content]
            resp.content_length = len(comp_content)

        resp.content_encoding = 'gzip'
        # TODO: regenerate etag?
        return resp
dataset/ETHPy150Open mahmoud/clastic/clastic/middleware/compress.py/GzipMiddleware.request/swapped operands of `in`