adding get-with-headers.py adding isolatin % hg serve % hgweb filerevision, html 200 Script output follows test:get-with-headers.py
changelog shortlog graph tags changeset files revisions annotate raw

get-with-headers.py

changeset 0: 7697c52ca9b0
author: test
date: Thu Jan 01 00:00:00 1970 +0000 (long ago)
permissions: -rwxr-xr-x
description: a
1#!/usr/bin/env python
2
3__doc__ = """This does HTTP get requests given a host:port and path and returns
4a subset of the headers plus the body of the result."""
5
6import httplib, sys
7
8try:
9 import msvcrt, os
10 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
11 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
12except ImportError:
13 pass
14
15headers = [h.lower() for h in sys.argv[3:]]
16conn = httplib.HTTPConnection(sys.argv[1])
17conn.request("GET", sys.argv[2])
18response = conn.getresponse()
19print response.status, response.reason
20for h in headers:
21 if response.getheader(h, None) is not None:
22 print "%s: %s" % (h, response.getheader(h))
23print
24sys.stdout.write(response.read())
25
26if 200 <= response.status <= 299:
27 sys.exit(0)
28sys.exit(1)
% hgweb filerevision, html 200 Script output follows test:isolatin
changelog shortlog graph tags changeset files revisions annotate raw

isolatin

changeset 0: 7697c52ca9b0
author: test
date: Thu Jan 01 00:00:00 1970 +0000 (long ago)
permissions: -rw-r--r--
description: a
1h?bsch
% hgweb fileannotate, html 200 Script output follows test: get-with-headers.py annotate
changelog shortlog graph tags changeset files file revisions raw

Annotate get-with-headers.py

changeset 0: 7697c52ca9b0
author: test
date: Thu Jan 01 00:00:00 1970 +0000 (long ago)
permissions: -rwxr-xr-x
description: a

test@0 1
#!/usr/bin/env python
test@0 2
test@0 3
__doc__ = """This does HTTP get requests given a host:port and path and returns
test@0 4
a subset of the headers plus the body of the result."""
test@0 5
test@0 6
import httplib, sys
test@0 7
test@0 8
try:
test@0 9
    import msvcrt, os
test@0 10
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
test@0 11
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
test@0 12
except ImportError:
test@0 13
    pass
test@0 14
test@0 15
headers = [h.lower() for h in sys.argv[3:]]
test@0 16
conn = httplib.HTTPConnection(sys.argv[1])
test@0 17
conn.request("GET", sys.argv[2])
test@0 18
response = conn.getresponse()
test@0 19
print response.status, response.reason
test@0 20
for h in headers:
test@0 21
    if response.getheader(h, None) is not None:
test@0 22
        print "%s: %s" % (h, response.getheader(h))
test@0 23
print
test@0 24
sys.stdout.write(response.read())
test@0 25
test@0 26
if 200 <= response.status <= 299:
test@0 27
    sys.exit(0)
test@0 28
sys.exit(1)
% hgweb fileannotate, raw % hgweb filerevision, raw % hgweb highlightcss friendly 200 Script output follows /* pygments_style = friendly */ % errors encountered % hg serve again % hgweb highlightcss fruity 200 Script output follows /* pygments_style = fruity */ % errors encountered