##// END OF EJS Templates
tests: extend get-with-headers to support cache testing
Dirkjan Ochtman -
r12182:1121af23 default
parent child Browse files
Show More
@@ -12,18 +12,40 b' try:'
12 except ImportError:
12 except ImportError:
13 pass
13 pass
14
14
15 headers = [h.lower() for h in sys.argv[3:]]
15 twice = False
16 conn = httplib.HTTPConnection(sys.argv[1])
16 if '--twice' in sys.argv:
17 conn.request("GET", sys.argv[2])
17 sys.argv.remove('--twice')
18 response = conn.getresponse()
18 twice = True
19 print response.status, response.reason
19
20 for h in headers:
20 tag = None
21 if response.getheader(h, None) is not None:
21 def request(host, path, show):
22 print "%s: %s" % (h, response.getheader(h))
22
23 print
23 global tag
24 data = response.read()
24 headers = {}
25 sys.stdout.write(data)
25 if tag:
26 headers['If-None-Match'] = tag
26
27
27 if 200 <= response.status <= 299:
28 conn = httplib.HTTPConnection(host)
29 conn.request("GET", path, None, headers)
30 response = conn.getresponse()
31 print response.status, response.reason
32 for h in [h.lower() for h in show]:
33 if response.getheader(h, None) is not None:
34 print "%s: %s" % (h, response.getheader(h))
35
36 print
37 data = response.read()
38 sys.stdout.write(data)
39
40 if twice and response.getheader('ETag', None):
41 tag = response.getheader('ETag')
42
43 return response.status
44
45 status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
46 if twice:
47 status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
48
49 if 200 <= status <= 305:
28 sys.exit(0)
50 sys.exit(0)
29 sys.exit(1)
51 sys.exit(1)
@@ -43,7 +43,7 b' cat hg.pid >> $DAEMON_PIDS'
43 python -c "print len(file('access.log').readlines()), 'log lines written'"
43 python -c "print len(file('access.log').readlines()), 'log lines written'"
44
44
45 echo % static file
45 echo % static file
46 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/static/style-gitweb.css'
46 "$TESTDIR/get-with-headers.py" --twice localhost:$HGPORT '/static/style-gitweb.css'
47
47
48 echo % errors
48 echo % errors
49 cat errors.log
49 cat errors.log
General Comments 0
You need to be logged in to leave comments. Login now