self.send_header('Content-length', str(len(str(content))))
self.send_header('Content-Encoding', 'gzip')
self.end_headers()
self.wfile.write(content)
self.wfile.flush()
How to use Content-Encoding: gzip with Python SimpleHTTPServer