2015-08-02 09:27:01 +00:00
|
|
|
from netlib import odict
|
2015-07-14 21:02:14 +00:00
|
|
|
|
2015-08-10 18:44:36 +00:00
|
|
|
|
2015-08-02 09:27:01 +00:00
|
|
|
class HttpError(Exception):
|
2015-08-10 18:44:36 +00:00
|
|
|
|
2015-07-14 21:02:14 +00:00
|
|
|
def __init__(self, code, message):
|
|
|
|
super(HttpError, self).__init__(message)
|
|
|
|
self.code = code
|
|
|
|
|
|
|
|
|
|
|
|
class HttpErrorConnClosed(HttpError):
|
|
|
|
pass
|
2015-08-01 08:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HttpAuthenticationError(Exception):
|
2015-08-10 18:44:36 +00:00
|
|
|
|
2015-08-01 08:39:14 +00:00
|
|
|
def __init__(self, auth_headers=None):
|
|
|
|
super(HttpAuthenticationError, self).__init__(
|
|
|
|
"Proxy Authentication Required"
|
|
|
|
)
|
2015-08-02 09:27:01 +00:00
|
|
|
if isinstance(auth_headers, dict):
|
|
|
|
auth_headers = odict.ODictCaseless(auth_headers.items())
|
2015-08-01 08:39:14 +00:00
|
|
|
self.headers = auth_headers
|
|
|
|
self.code = 407
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "Proxy Authentication Required"
|