[PATCH 20 of 22 V2-Series-D] get-with-headers: add a --headeronly switch
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Mon Jan 14 14:35:52 CST 2013
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1358195035 -3600
# Node ID cd73d1a61f4243c73b702ca266ef0fc8a0dca467
# Parent e7888fbf2a7d88d9674d392f36575b67ca9ef5ea
get-with-headers: add a --headeronly switch
In some case we do not care about the actual rendering.
diff --git a/tests/get-with-headers.py b/tests/get-with-headers.py
--- a/tests/get-with-headers.py
+++ b/tests/get-with-headers.py
@@ -14,10 +14,14 @@ except ImportError:
twice = False
if '--twice' in sys.argv:
sys.argv.remove('--twice')
twice = True
+headonly = False
+if '--headeronly' in sys.argv:
+ sys.argv.remove('--headeronly')
+ headonly = True
reasons = {'Not modified': 'Not Modified'} # python 2.4
tag = None
def request(host, path, show):
@@ -32,17 +36,17 @@ def request(host, path, show):
response = conn.getresponse()
print response.status, reasons.get(response.reason, response.reason)
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 headonly:
+ 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
status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
if twice:
More information about the Mercurial-devel
mailing list