blob: 7586a1020121b8e6b908c81f0e86dbe6344c95e6 (
plain) (
tree)
|
|
--- a/urllib2_kerberos.py
+++ b/urllib2_kerberos.py
@@ -62,8 +62,8 @@ class AbstractKerberosAuthHandler:
host = req.get_host()
log.debug("req.get_host() returned %s" % host)
- tail, sep, head = host.rpartition(':')
- domain = tail if tail else head
+ cindex = host.rfind(':')
+ domain = (cindex == -1) and host or host[:cindex]
result, self.context = k.authGSSClientInit("HTTP@%s" % domain)
@@ -130,15 +130,15 @@ class AbstractKerberosAuthHandler:
if resp.getcode() != 200:
self.authenticate_server(resp.info())
+ self.clean_context()
+ self.retried = 0
return resp
except k.GSSError, e:
log.critical("GSSAPI Error: %s/%s" % (e[0][0], e[1][0]))
- return None
-
- finally:
self.clean_context()
self.retried = 0
+ return None
class ProxyKerberosAuthHandler(u2.BaseHandler, AbstractKerberosAuthHandler):
"""Kerberos Negotiation handler for HTTP proxy auth
|