Fixed bug [ 1529838 ] Non-existent URI
diff --git a/httplib2/__init__.py b/httplib2/__init__.py
index 6ad8afe..b5c61f3 100644
--- a/httplib2/__init__.py
+++ b/httplib2/__init__.py
@@ -83,6 +83,7 @@
class UnimplementedDigestAuthOptionError(HttpLib2Error): pass
class UnimplementedHmacDigestAuthOptionError(HttpLib2Error): pass
class RelativeURIError(HttpLib2Error): pass
+class ServerNotFoundError(HttpLib2Error): pass
# Open Items:
# -----------
@@ -657,6 +658,8 @@
try:
conn.request(method, request_uri, body, headers)
response = conn.getresponse()
+ except gaierror:
+ raise ServerNotFoundError("Unable to find the server at %s" % request_uri)
except:
if i == 0:
conn.close()
diff --git a/httplib2test.py b/httplib2test.py
index 33e50d6..4839559 100755
--- a/httplib2test.py
+++ b/httplib2test.py
@@ -83,6 +83,13 @@
self.http = httplib2.Http(cacheDirName)
self.http.clear_credentials()
+ def testGetUnknownServer(self):
+ try:
+ self.http.request("http://fred.bitworking.org/")
+ self.fail("An httplib2.ServerNotFoundError Exception must be thrown on an unresolvable server.")
+ except httplib2.ServerNotFoundError:
+ pass
+
def testGetIRI(self):
if sys.version_info >= (2,3):
uri = urlparse.urljoin(base, u"reflector/reflector.cgi?d=\N{CYRILLIC CAPITAL LETTER DJE}")