tests/get-with-headers.py
changeset 30764 e75463e3179f
parent 29455 0c741fd6158a
child 31791 39f6333e968c
equal deleted inserted replaced
30763:a520aefb96f1 30764:e75463e3179f
    33 formatjson = False
    33 formatjson = False
    34 if '--json' in sys.argv:
    34 if '--json' in sys.argv:
    35     sys.argv.remove('--json')
    35     sys.argv.remove('--json')
    36     formatjson = True
    36     formatjson = True
    37 
    37 
       
    38 hgproto = None
       
    39 if '--hgproto' in sys.argv:
       
    40     idx = sys.argv.index('--hgproto')
       
    41     hgproto = sys.argv[idx + 1]
       
    42     sys.argv.pop(idx)
       
    43     sys.argv.pop(idx)
       
    44 
    38 tag = None
    45 tag = None
    39 def request(host, path, show):
    46 def request(host, path, show):
    40     assert not path.startswith('/'), path
    47     assert not path.startswith('/'), path
    41     global tag
    48     global tag
    42     headers = {}
    49     headers = {}
    43     if tag:
    50     if tag:
    44         headers['If-None-Match'] = tag
    51         headers['If-None-Match'] = tag
       
    52     if hgproto:
       
    53         headers['X-HgProto-1'] = hgproto
    45 
    54 
    46     conn = httplib.HTTPConnection(host)
    55     conn = httplib.HTTPConnection(host)
    47     conn.request("GET", '/' + path, None, headers)
    56     conn.request("GET", '/' + path, None, headers)
    48     response = conn.getresponse()
    57     response = conn.getresponse()
    49     print(response.status, response.reason)
    58     print(response.status, response.reason)