ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

87 lines
2.9 KiB

  1. #!/usr/bin/env python
  2. # coding=utf-8
  3. # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
  4. import sys
  5. import socket
  6. import time
  7. import os.path
  8. import traceback
  9. import random
  10. import toscgi
  11. import tofcgi
  12. def load_file(file_name):
  13. file_name = os.path.dirname(sys.argv[0]) + "/" + file_name
  14. f=open(file_name,'rb')
  15. input=f.read()
  16. f.close()
  17. return input
  18. def test_io(input,socket_type,target):
  19. try:
  20. s=socket.socket(socket_type,socket.SOCK_STREAM);
  21. try:
  22. s.connect(target)
  23. if socket_type==socket.AF_INET:
  24. s.setsockopt(socket.IPPROTO_TCP,socket.TCP_NODELAY,1)
  25. s.sendall(input)
  26. for x in xrange(0,100):
  27. chunk = s.recv(1024)
  28. if chunk == '':
  29. break
  30. except socket.error:
  31. pass
  32. s.close();
  33. except socket.error:
  34. pass
  35. def usege():
  36. print './disco_test.py (http|fastcgi_tcp|scgi_tcp|fastcgi_unix|scgi_unix)'
  37. test=sys.argv[1]
  38. if test=='http' or test=='fastcgi_tcp' or test=='scgi_tcp':
  39. target=('localhost',8080)
  40. socket_type=socket.AF_INET
  41. else:
  42. target=('/tmp/cppcms_test_socket')
  43. socket_type=socket.AF_UNIX
  44. if test=='http':
  45. input = load_file('disco_test_norm.in');
  46. test_io(input,socket_type,target);
  47. input = load_file('disco_test_gzip.in');
  48. test_io(input,socket_type,target);
  49. input = load_file('disco_test_async_multiple.in');
  50. test_io(input,socket_type,target);
  51. input = load_file('disco_test_async_single.in');
  52. test_io(input,socket_type,target);
  53. input = load_file('disco_test_async_nonblocking.in');
  54. test_io(input,socket_type,target);
  55. elif test=='fastcgi_tcp' or test=='fastcgi_unix':
  56. input = tofcgi.to_fcgi_request(load_file('disco_test_norm_cgi.in'));
  57. test_io(input,socket_type,target);
  58. input = tofcgi.to_fcgi_request(load_file('disco_test_gzip_cgi.in'));
  59. test_io(input,socket_type,target);
  60. input = tofcgi.to_fcgi_request(load_file('disco_test_async_cgi_multiple.in'));
  61. test_io(input,socket_type,target);
  62. input = tofcgi.to_fcgi_request(load_file('disco_test_async_cgi_single.in'));
  63. test_io(input,socket_type,target);
  64. input = tofcgi.to_fcgi_request(load_file('disco_test_async_cgi_nonblocking.in'));
  65. test_io(input,socket_type,target);
  66. elif test=='scgi_tcp' or test=='scgi_unix':
  67. input = toscgi.toscgi(load_file('disco_test_norm_cgi.in'));
  68. test_io(input,socket_type,target);
  69. input = toscgi.toscgi(load_file('disco_test_gzip_cgi.in'));
  70. test_io(input,socket_type,target);
  71. input = toscgi.toscgi(load_file('disco_test_async_cgi_multiple.in'));
  72. test_io(input,socket_type,target);
  73. input = toscgi.toscgi(load_file('disco_test_async_cgi_single.in'));
  74. test_io(input,socket_type,target);
  75. input = toscgi.toscgi(load_file('disco_test_async_cgi_nonblocking.in'));
  76. test_io(input,socket_type,target);
  77. else:
  78. usege()
  79. time.sleep(0.5);