Skip to content

Instantly share code, notes, and snippets.

@vi4m
Created September 17, 2016 20:25
Show Gist options
  • Save vi4m/a3809caea5e4a59d27e1032f8b9657f1 to your computer and use it in GitHub Desktop.
Save vi4m/a3809caea5e4a59d27e1032f8b9657f1 to your computer and use it in GitHub Desktop.
zewo bug - server.py
#!/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