Commits

Maciej Fijalkowski  committed 98c2aec

Fixes comments and a tornado example

  • Participants
  • Parent commits 577b7b5

Comments (0)

Files changed (2)

File asynchammer/asynchammer.py

+
+""" Hammer a web server (it's a bit buggy, but should work, assumes all the
+headers arrive in one piece)
+
+You migth want to do this on your system as root (allegedly a security conern):
+
+sysctl -w net.ipv4.tcp_timestamps=1
+sysctl -w net.ipv4.tcp_tw_recycle=1
+
+"""
 
 from twisted.internet import epollreactor
 epollreactor.install()
 
 "Connection: keep-alive"
 
-HTTP_REQ = """GET / HTTP/1.1
+HTTP_REQ = ("""GET / HTTP/1.1
 Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
 Accept-Encoding:sdch
 X-Chrome-UMA-Enabled:1
 X-Chrome-Variations:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
 
-""" % {'cookie': 'a' * 100}
+""" % {'cookie': 'a' * 100}).replace('\n', '\r\n')
 
 CL = len('Content-length: ')
 

File asynchammer/tornado_example.py

+import tornado.ioloop
+import tornado.web
+
+class MainHandler(tornado.web.RequestHandler):
+    def get(self):
+        self.write("Hello, world")
+
+application = tornado.web.Application([
+    (r"/", MainHandler),
+])
+
+if __name__ == "__main__":
+    application.listen(8888)
+    tornado.ioloop.IOLoop.instance().start()
+