'Encode the content with the given encoding (only gzip and
identity are supported).'

def encode_content(self, encoding='gzip', lazy=False):

    assert (encoding in ('identity', 'gzip')), ('Unknown    encoding:    %r' % encoding)
    if (encoding == 'identity'):
        self.decode_content()
        return
    if (self.content_encoding == 'gzip'):
        return
    if lazy:
        self.app_iter = gzip_app_iter(self._app_iter)
        self.content_length = None
    else:
        self.app_iter = list(gzip_app_iter(self._app_iter))
        self.content_length = sum(map(len, self._app_iter))
    self.content_encoding = 'gzip'
