From cae7bdb4241b928f9da025dce48ec98f1b63d576 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Sun, 5 Apr 2015 19:26:29 -0400 Subject: #3566: Clean up handling of remote server disconnects. This changeset does two things: introduces a new RemoteDisconnected exception (that subclasses ConnectionResetError and BadStatusLine) so that a remote server disconnection can be detected by client code (and provides a better error message for debugging purposes), and ensures that the client socket is closed if a ConnectionError happens, so that the automatic re-connection code can work if the application handles the error and continues on. Tests are added that confirm that a connection is re-used or not re-used as appropriate to the various combinations of protocol version and headers. Patch by Martin Panter, reviewed by Demian Brecht. (Tweaked only slightly by me.) --- Lib/xmlrpc/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/xmlrpc/client.py') diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index 34208d1c75..da089a2f03 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -1128,7 +1128,7 @@ class Transport: if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE): raise - except http.client.BadStatusLine: #close after we sent request + except http.client.RemoteDisconnected: if i: raise -- cgit v1.2.1