[PATCH 01 of 15 V3] get-with-headers: add a --headeronly switch

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Wed Jan 16 07:32:07 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1358342779 -3600
# Node ID f1118507174b87df64115ebd3bfd45ee2e21932f
# Parent  66cec3c2ee00abbcaa0813eb01f34f7123eb3b49
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
+headeronly = False
+if '--headeronly' in sys.argv:
+    sys.argv.remove('--headeronly')
+    headeronly = True
 
 reasons = {'Not modified': 'Not Modified'} # python 2.4
 
 tag = None
 def request(host, path, show):
@@ -35,17 +39,17 @@ def request(host, path, show):
         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
 
 status = request(sys.argv[1], sys.argv[2], sys.argv[3:])
 if twice:


More information about the Mercurial-devel mailing list