Add test for urldecode()
[darkhttpd] / torture.py
1 #!/usr/bin/env python
2 import sys, socket
3
4 request = (
5 'GET /darkhttpd.c HTTP/1.0\r\n'
6 '\r\n'
7 )
8
9 s = socket.socket()
10 s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
11 s.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1)
12 #s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 1)
13 #^ for some reason, this un-cripples the receiving buffer
14 try:
15 s.connect(("", 8089))
16 except socket.error, e:
17 print "ERROR: darkhttpd not running?"
18 print "Run: cd trunk && ./darkhttpd . --port 8089"
19 print ""
20 raise e
21
22 print "(start sending)"
23
24 for i in request:
25 numsent = s.send(i)
26 if numsent != 1:
27 raise Exception, "couldn't send"
28 sys.stdout.write(i)
29 sys.stdout.flush()
30
31 print "(done sending - start receiving)"
32
33 while True:
34 c = s.recv(1)
35 if c == '':
36 print "(done receiving)"
37 break
38 sys.stdout.write(c)
39 sys.stdout.flush()
40
41 # vim:set sw=4 ts=4 et tw=78: