'Returns a GZip compressed response with given ``content`` and correct headers
:type content: str
:type compression: int
:rtype: str'

def gzip(self, content, compression=9):

    io = StringIO()
    gz = gzip.GzipFile('', 'wb', compression, io)
    gz.write(content)
    gz.close()
    compressed = io.getvalue()
    self.add_header('Content-Length', str(len(compressed)))
    self.add_header('Content-Encoding', 'gzip')
    self.respond_ok()
    return compressed
