path = "/"
return scheme, host, port, path
+class BadResponse(object):
+ def __init__(self, url, err):
+ self.status = -1
+ self.reason = "Error trying to connect to %s: %s" % (url, err)
+ def read(self):
+ return ""
+
def do_http(method, url, body=""):
if isinstance(body, str):
try:
c.endheaders()
except socket_error, err:
- class BadResponse(object):
- status=-1
- reason="Error trying to connect to %s: %s" % (url, err)
- read=lambda _: ""
- return BadResponse()
-
+ return BadResponse(url, err)
+
while True:
data = body.read(8192)
if not data:
self.set_up_grid()
# Simulate a connection error
- endheaders = allmydata.scripts.common_http.httplib.HTTPConnection.endheaders
- def _fix_endheaders(*args):
- allmydata.scripts.common_http.httplib.HTTPConnection.endheaders = endheaders
def _socket_error(*args, **kwargs):
raise socket_error('test error')
- allmydata.scripts.common_http.httplib.HTTPConnection.endheaders = _socket_error
+ self.patch(allmydata.scripts.common_http.httplib.HTTPConnection,
+ "endheaders", _socket_error)
d = self.do_cli("mkdir")
def _check_invalid((rc,stdout,stderr)):
self.failIfEqual(rc, 0)
self.failUnlessIn("Error trying to connect to http://127.0.0.1", stderr)
d.addCallback(_check_invalid)
- d.addCallback(_fix_endheaders)
return d