comparison tests/get-with-headers.py @ 23409:dc4d2cd3aa3e stable

hgweb: send proper HTTP response after uncaught exception This patch fixes a bug where hgweb would send an incomplete HTTP response. If an uncaught exception is raised when hgweb is processing a request, hgweb attempts to send a generic error response and log that exception. The server defaults to chunked transfer coding. If an uncaught exception occurred, it was sending the error response string / chunk properly. However, RFC 7230 Section 4.1 mandates a 0 size last chunk be sent to indicate end of the entity body. hgweb was failing to send this last chunk. As a result, properly written HTTP clients would assume more data was coming and they would likely time out waiting for another chunk to arrive. Mercurial's own test harness was paving over the improper HTTP behavior by not attempting to read the response body if the status code was 500. This incorrect workaround was added in ba6577a19656 and has been removed with this patch.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 28 Nov 2014 10:59:02 -0800
parents ba6577a19656
children 747401086a38
comparison
equal deleted inserted replaced
23403:edf29f9c15f0 23409:dc4d2cd3aa3e
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 if response.status != 500: 46 data = response.read()
47 data = response.read() 47 sys.stdout.write(data)
48 sys.stdout.write(data)
49 48
50 if twice and response.getheader('ETag', None): 49 if twice and response.getheader('ETag', None):
51 tag = response.getheader('ETag') 50 tag = response.getheader('ETag')
52 51
53 return response.status 52 return response.status