Created
September 17, 2016 20:25
-
-
Save vi4m/a3809caea5e4a59d27e1032f8b9657f1 to your computer and use it in GitHub Desktop.
zewo bug - server.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Demo Content-Length bug in Zewo | |
Usage:: | |
./dummy-web-server.py [<port>] | |
Send a GET request:: | |
curl http://localhost | |
""" | |
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | |
import SocketServer | |
class S(BaseHTTPRequestHandler): | |
def do_GET(self): | |
c = open("request.txt").read() | |
print(c) | |
self.wfile.write(c) | |
def run(server_class=HTTPServer, handler_class=S, port=80): | |
server_address = ('', port) | |
httpd = server_class(server_address, handler_class) | |
print 'Starting httpd...' | |
httpd.serve_forever() | |
if __name__ == "__main__": | |
from sys import argv | |
if len(argv) == 2: | |
run(port=int(argv[1])) | |
else: | |
run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment