equal
deleted
inserted
replaced
1 #!/usr/bin/env python |
1 #!/usr/bin/env python |
2 |
2 |
3 __doc__ = """This does HTTP get requests given a host:port and path and returns |
3 __doc__ = """This does HTTP get requests given a host:port and path and returns |
4 a subset of the headers plus the body of the result.""" |
4 a subset of the headers plus the body of the result.""" |
5 |
5 |
6 import httplib, sys |
6 import httplib, sys, re |
7 |
7 |
8 try: |
8 try: |
9 import msvcrt, os |
9 import msvcrt, os |
10 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
10 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
11 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
11 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
19 print response.status, response.reason |
19 print response.status, response.reason |
20 for h in headers: |
20 for h in headers: |
21 if response.getheader(h, None) is not None: |
21 if response.getheader(h, None) is not None: |
22 print "%s: %s" % (h, response.getheader(h)) |
22 print "%s: %s" % (h, response.getheader(h)) |
23 print |
23 print |
24 sys.stdout.write(response.read()) |
24 data = response.read() |
|
25 data = re.sub('\d+ years', 'many years', data) |
|
26 sys.stdout.write(data) |
25 |
27 |
26 if 200 <= response.status <= 299: |
28 if 200 <= response.status <= 299: |
27 sys.exit(0) |
29 sys.exit(0) |
28 sys.exit(1) |
30 sys.exit(1) |