2020-01-01 10:07:14 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import gzip, string, six, os, time, http.server
|
2008-03-01 07:53:33 -05:00
|
|
|
|
2020-01-01 10:07:14 -05:00
|
|
|
data = [str(i) for i in range(34000)]
|
2008-03-01 07:53:33 -05:00
|
|
|
text = "\n".join(data)
|
2020-01-01 10:07:14 -05:00
|
|
|
s = six.BytesIO()
|
2008-03-01 07:53:33 -05:00
|
|
|
gz = gzip.GzipFile("1.gz", "wb", 9, s)
|
2020-01-01 10:07:14 -05:00
|
|
|
gz.write(bytes(text, 'iso8859-1'))
|
2008-03-01 07:53:33 -05:00
|
|
|
gz.close()
|
|
|
|
comp = s.getvalue()
|
|
|
|
s.close()
|
|
|
|
pocz = comp[:65536]
|
|
|
|
reszta = comp[65536:]
|
|
|
|
|
2020-01-01 10:07:14 -05:00
|
|
|
class obsluga(http.server.BaseHTTPRequestHandler):
|
|
|
|
def do_GET(self):
|
|
|
|
self.send_response(200)
|
|
|
|
self.send_header("Content-Type", "text/plain")
|
|
|
|
self.send_header("Content-Encoding", "gzip")
|
|
|
|
self.send_header("Connection", "close")
|
|
|
|
self.end_headers()
|
|
|
|
self.wfile.write(pocz)
|
|
|
|
time.sleep(5)
|
|
|
|
self.wfile.write(reszta)
|
2008-03-01 07:53:33 -05:00
|
|
|
|
|
|
|
def run(port=8900):
|
2020-01-01 10:07:14 -05:00
|
|
|
server_address = ('127.0.0.1', port)
|
|
|
|
httpd = http.server.HTTPServer(server_address, obsluga)
|
|
|
|
httpd.handle_request()
|
2008-03-01 07:53:33 -05:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-01-01 10:07:14 -05:00
|
|
|
run()
|