X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=src%2Fallmydata%2Fscripts%2Fcommon_http.py;h=7ffa41bddba37eb307eb3cf43ae6cb060d197cfa;hb=4f19f2b4b4c038c7b6e557c5c114e5459da36898;hp=66a6291cb5497e3ec89a60a990a5d2917525d860;hpb=ca620a6ce195ff177f5ef64dc91558968db2360b;p=tahoe-lafs%2Ftahoe-lafs.git diff --git a/src/allmydata/scripts/common_http.py b/src/allmydata/scripts/common_http.py index 66a6291c..7ffa41bd 100644 --- a/src/allmydata/scripts/common_http.py +++ b/src/allmydata/scripts/common_http.py @@ -6,7 +6,7 @@ import allmydata # for __full_version__ from allmydata.util.encodingutil import quote_output from allmydata.scripts.common import TahoeError - +from socket import error as socket_error # copied from twisted/web/client.py def parse_url(url, defaultPort=None): @@ -58,8 +58,16 @@ def do_http(method, url, body=""): length = body.tell() body.seek(old) c.putheader("Content-Length", str(length)) - c.endheaders() + 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() + while True: data = body.read(8192) if not data: