mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-02 08:57:19 -04:00
test: a http server to test the decompression on Windows.
Run: python w32.py. The server listens on port 8900. It handles only one request. The proper output are numbers 0 through 33999. I have no free disk to test it, but I'm afraid that the ELinks will hang on Windows after reading 65536 bytes. Let me know of results of such a test. The ELinks must be compiled with the zlib library.
This commit is contained in:
parent
c48dc625e3
commit
faa47cea6f
32
test/server/w32.py
Executable file
32
test/server/w32.py
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import gzip, string, cStringIO, os, time, BaseHTTPServer
|
||||||
|
|
||||||
|
data = [str(i) for i in xrange(34000)]
|
||||||
|
text = "\n".join(data)
|
||||||
|
s = cStringIO.StringIO()
|
||||||
|
gz = gzip.GzipFile("1.gz", "wb", 9, s)
|
||||||
|
gz.write(text)
|
||||||
|
gz.close()
|
||||||
|
comp = s.getvalue()
|
||||||
|
s.close()
|
||||||
|
pocz = comp[:65536]
|
||||||
|
reszta = comp[65536:]
|
||||||
|
|
||||||
|
class obsluga(BaseHTTPServer.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)
|
||||||
|
|
||||||
|
def run(port=8900):
|
||||||
|
server_address = ('127.0.0.1', port)
|
||||||
|
httpd = BaseHTTPServer.HTTPServer(server_address, obsluga)
|
||||||
|
httpd.handle_request()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run()
|
Loading…
Reference in New Issue
Block a user