tests/get-with-headers.py
changeset 47582 6bceecb28806
parent 47500 23f5ed6dbcb1
child 48875 6000f5b25c9b
equal deleted inserted replaced
47581:28a914b3d4ce 47582:6bceecb28806
    82         if response.getheader(h, None) is not None:
    82         if response.getheader(h, None) is not None:
    83             stdout.write(
    83             stdout.write(
    84                 b"%s: %s\n"
    84                 b"%s: %s\n"
    85                 % (h.encode('ascii'), response.getheader(h).encode('ascii'))
    85                 % (h.encode('ascii'), response.getheader(h).encode('ascii'))
    86             )
    86             )
    87     if not headeronly:
    87     if headeronly:
       
    88         # still read the body to prevent windows to be unhappy about that
       
    89         # (this might some flakyness in test-hgweb-filelog.t on Windows)
       
    90         data = response.read()
       
    91     else:
    88         stdout.write(b'\n')
    92         stdout.write(b'\n')
    89         data = response.read()
    93         data = response.read()
    90 
    94 
    91         if args.bodyfile:
    95         if args.bodyfile:
    92             bodyfh = open(args.bodyfile, 'wb')
    96             bodyfh = open(args.bodyfile, 'wb')
   110             bodyfh.close()
   114             bodyfh.close()
   111 
   115 
   112     if twice and response.getheader('ETag', None):
   116     if twice and response.getheader('ETag', None):
   113         tag = response.getheader('ETag')
   117         tag = response.getheader('ETag')
   114 
   118 
       
   119     # further try to please the windows-flakyness deity
       
   120     conn.close()
       
   121 
   115     return response.status
   122     return response.status
   116 
   123 
   117 
   124 
   118 status = request(args.host, args.path, args.show)
   125 status = request(args.host, args.path, args.show)
   119 if twice:
   126 if twice: