[PATCH] get-with-headers: don't block indefinitely if the server had an internal error

Javi Merino cibervicho at gmail.com
Wed Oct 2 17:03:19 CDT 2013


# HG changeset patch
# User Javi Merino <cibervicho at gmail.com>
# Date 1380750392 -3600
#      Wed Oct 02 22:46:32 2013 +0100
# Node ID c135513fb69b57d869eb98c23cef2f5c3fab54e7
# Parent  1935e8383a9e1bd1ac6809ad1ecafd42dd7d58b2
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.

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
@@ -43,8 +43,9 @@ def request(host, path, show):
             print "%s: %s" % (h, response.getheader(h))
     if not headeronly:
         print
-        data = response.read()
-        sys.stdout.write(data)
+        if response.status != 500:
+            data = response.read()
+            sys.stdout.write(data)
 
         if twice and response.getheader('ETag', None):
             tag = response.getheader('ETag')


More information about the Mercurial-devel mailing list