Mercurial > public > mercurial-scm > hg
comparison tests/get-with-headers.py @ 12250:bd98796c0b6f
tests: fix incompatibility with python-2.4 in test-hgweb
Thanks to lcantey for catching it.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sat, 11 Sep 2010 10:57:35 +0200 |
parents | 1121af239761 |
children | 953faba28e91 |
comparison
equal
deleted
inserted
replaced
12211:798d72f3621c | 12250:bd98796c0b6f |
---|---|
15 twice = False | 15 twice = False |
16 if '--twice' in sys.argv: | 16 if '--twice' in sys.argv: |
17 sys.argv.remove('--twice') | 17 sys.argv.remove('--twice') |
18 twice = True | 18 twice = True |
19 | 19 |
20 reasons = {'Not modified': 'Not Modified'} # python 2.4 | |
21 | |
20 tag = None | 22 tag = None |
21 def request(host, path, show): | 23 def request(host, path, show): |
22 | 24 |
23 global tag | 25 global tag |
24 headers = {} | 26 headers = {} |
26 headers['If-None-Match'] = tag | 28 headers['If-None-Match'] = tag |
27 | 29 |
28 conn = httplib.HTTPConnection(host) | 30 conn = httplib.HTTPConnection(host) |
29 conn.request("GET", path, None, headers) | 31 conn.request("GET", path, None, headers) |
30 response = conn.getresponse() | 32 response = conn.getresponse() |
31 print response.status, response.reason | 33 print response.status, reasons.get(response.reason, response.reason) |
32 for h in [h.lower() for h in show]: | 34 for h in [h.lower() for h in show]: |
33 if response.getheader(h, None) is not None: | 35 if response.getheader(h, None) is not None: |
34 print "%s: %s" % (h, response.getheader(h)) | 36 print "%s: %s" % (h, response.getheader(h)) |
35 | 37 |
36 print | 38 print |