Fix issue #62 by trentm
diff --git a/python2/httplib2/__init__.py b/python2/httplib2/__init__.py
index b21bf15..3054051 100644
--- a/python2/httplib2/__init__.py
+++ b/python2/httplib2/__init__.py
@@ -41,6 +41,7 @@
 import calendar
 import time
 import random
+import errno
 # remove depracated warning in python2.6
 try:
     from hashlib import sha1 as _sha, md5 as _md5
@@ -865,7 +866,10 @@
             except socket.gaierror:
                 conn.close()
                 raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
-            except (socket.error, httplib.HTTPException):
+            except socket.error, e:
+                if e.errno == errno.ECONNREFUSED: # Connection refused
+                    raise
+            except httplib.HTTPException:
                 # Just because the server closed the connection doesn't apparently mean
                 # that the server didn't send a response.
                 pass
diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py
index f7b346b..ccd4d46 100644
--- a/python3/httplib2/__init__.py
+++ b/python3/httplib2/__init__.py
@@ -43,6 +43,7 @@
 import calendar
 import time
 import random
+import errno
 from hashlib import sha1 as _sha, md5 as _md5
 import hmac
 from gettext import gettext as _
@@ -850,7 +851,11 @@
             except socket.gaierror:
                 conn.close()
                 raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
-            except (socket.error, httplib.HTTPException):
+            except socket.error as e:
+                errno_ = (e.args[0].errno if isinstance(e.args[0], socket.error) else e.errno)
+                if errno_ == errno.ECONNREFUSED: # Connection refused
+                    raise
+            except httplib.HTTPException:
                 # Just because the server closed the connection doesn't apparently mean
                 # that the server didn't send a response.
                 pass