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

login
register
mail settings
Submitter Javi Merino
Date Oct. 2, 2013, 10:03 p.m.
Message ID <c135513fb69b57d869eb.1380751399@tesla>
Download mbox | patch
Permalink /patch/2712/
State Superseded
Commit ba6577a196560d4a2925fc844520d75dedb28861
Headers show

Comments

Javi Merino - Oct. 2, 2013, 10:03 p.m.
# HG changeset patch
# User Javi Merino <cibervicho@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.
Augie Fackler - Oct. 3, 2013, 2:45 p.m.
On Wed, Oct 02, 2013 at 11:03:19PM +0100, Javi Merino wrote:
> # HG changeset patch
> # User Javi Merino <cibervicho@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.

Bwuh? There can be a body on a 500. This strikes me as probably
wrong. Can you give an example of a case that hangs?

>
> 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')
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

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')