1
|
1 #!/usr/bin/env python
|
|
2
|
|
3 """
|
|
4 dump HTTP requests
|
|
5 """
|
|
6
|
2
|
7 # imports
|
1
|
8 import optparse
|
3
|
9 import os
|
2
|
10 import sys
|
3
|
11 import time
|
1
|
12 import wsgiref
|
|
13
|
|
14 class RequestDumpster(object):
|
|
15
|
3
|
16 def __init__(self, directory=None):
|
|
17 if directory is not None and not os.path.isdir(directory):
|
|
18 raise Exception("Not a directory")
|
|
19 self.directory = directory
|
|
20
|
1
|
21
|
|
22 def __call__(self, environ, start_response):
|
|
23 """WSGI"""
|
|
24
|
|
25 def main(args=sys.argv[1:]):
|
|
26 """CLI"""
|
|
27
|
|
28 # parse command line arguments
|
|
29 parser = optparse.OptionParser(description=__doc__)
|
|
30 parser.add_option('-p', '--port', dest='port',
|
|
31 type='int', default=9555,
|
|
32 help="port to serve on")
|
|
33 options = parser.parse_args()
|
|
34
|
|
35 # construct url
|
|
36 url = 'http://localhost:{port}/'.format(port=options.port)
|
|
37
|
|
38 if __name__ == '__main__':
|
|
39 main()
|