comparison tests/get-with-headers.py @ 19865:ba6577a19656

get-with-headers: don't block indefinitely if the server had an internal error If the server had an internal error and returned 500, there's nothing to read, so "response.read()" blocks indefinitely. Only output the response if there's really a response.
author Javi Merino <cibervicho@gmail.com>
date Wed, 02 Oct 2013 22:46:32 +0100
parents f1118507174b
children dc4d2cd3aa3e
comparison
equal deleted inserted replaced
19864:1ce3f56b879f 19865:ba6577a19656
41 for h in [h.lower() for h in show]: 41 for h in [h.lower() for h in show]:
42 if response.getheader(h, None) is not None: 42 if response.getheader(h, None) is not None:
43 print "%s: %s" % (h, response.getheader(h)) 43 print "%s: %s" % (h, response.getheader(h))
44 if not headeronly: 44 if not headeronly:
45 print 45 print
46 data = response.read() 46 if response.status != 500:
47 sys.stdout.write(data) 47 data = response.read()
48 sys.stdout.write(data)
48 49
49 if twice and response.getheader('ETag', None): 50 if twice and response.getheader('ETag', None):
50 tag = response.getheader('ETag') 51 tag = response.getheader('ETag')
51 52
52 return response.status 53 return response.status