~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_urllib2_wrappers.py

  • Committer: Vincent Ladeuil
  • Date: 2009-08-19 16:33:39 UTC
  • mto: (4630.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4631.
  • Revision ID: v.ladeuil+lp@free.fr-20090819163339-80g9c3lad00wpe0v
More complete fix.

* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractHTTPHandler.retry_or_raise): ECONNRESET should be
translated into ConnectionReset. It's pretty rare that it can
occur during the request sending, but it has been observed during
selftest runs.

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._curl_perform): Turns CURLE_RECV_ERROR into a
ConnectionReset instead of a ConnectionError or some callers won't
catch it properly.

* bzrlib/transport/http/__init__.py:
(SmartClientHTTPMedium.send_http_smart_request): Catch
ConnectionReset and turn into a SmartProtocolError like for
InvalidHttpResponse.

* bzrlib/tests/test_http.py:
(TestWallServer.test_http_has, TestWallServer.test_http_get):
ConnectionReset can be raised too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
# actual code more or less do that, tests should be written to
47
47
# ensure that.
48
48
 
 
49
import errno
49
50
import httplib
50
51
try:
51
52
    import kerberos
541
542
                        request.get_full_url(),
542
543
                        'Bad status line received',
543
544
                        orig_error=exc_val)
 
545
                elif (isinstance(exc_val, socket.error) and len(exc_val.args)
 
546
                      and exc_val.args[0] in (errno.ECONNRESET, 10054)):
 
547
                    raise errors.ConnectionReset(
 
548
                        "Connection lost while sending request.")
544
549
                else:
545
550
                    # All other exception are considered connection related.
546
551