diff -r 5eb5ba3b9e99 -r e475cc6eff08 tests/get-with-headers.py --- a/tests/get-with-headers.py Thu Jan 10 16:25:06 2013 +0000 +++ b/tests/get-with-headers.py Wed Jan 16 20:56:02 2013 +0000 @@ -16,6 +16,10 @@ if '--twice' in sys.argv: sys.argv.remove('--twice') twice = True +headeronly = False +if '--headeronly' in sys.argv: + sys.argv.remove('--headeronly') + headeronly = True reasons = {'Not modified': 'Not Modified'} # python 2.4 @@ -31,16 +35,19 @@ conn.request("GET", '/' + path, None, headers) response = conn.getresponse() print response.status, reasons.get(response.reason, response.reason) + if show[:1] == ['-']: + show = sorted(h for h, v in response.getheaders() + if h.lower() not in show) for h in [h.lower() for h in show]: if response.getheader(h, None) is not None: print "%s: %s" % (h, response.getheader(h)) + if not headeronly: + print + data = response.read() + sys.stdout.write(data) - print - data = response.read() - sys.stdout.write(data) - - if twice and response.getheader('ETag', None): - tag = response.getheader('ETag') + if twice and response.getheader('ETag', None): + tag = response.getheader('ETag') return response.status