code: def _compress_content(self, content):
          
          zbuf = StringIO()
          zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
          zfile.write(content.read())
          zfile.close()
          content.file = zbuf
          return content
docs: Gzip a given string.