'Generates the gssapi authentication token with kerberos'

def generate_request_header(self, r):

    host = urlparse(r.url).netloc
    (tail, _, head) = host.rpartition(':')
    domain = (tail if tail else head)
    (result, self.context) = k.authGSSClientInit(('HTTP@%s' % domain))
    if (result < 1):
        raise Exception('authGSSClientInit    failed')
    result = k.authGSSClientStep(self.context, _negotiate_value(r))
    if (result < 0):
        raise Exception('authGSSClientStep    failed')
    response = k.authGSSClientResponse(self.context)
    return ('Negotiate    %s' % response)
