#!/usr/bin/env python

# $Id: fix_auth_failure.py,v 1.1 2011-02-15 20:28:38 barry409 Exp $

# Copyright (c) 2011 Board of Trustees of Leland Stanford Jr. University,
# all rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# STANFORD UNIVERSITY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of Stanford University shall not
# be used in advertising or otherwise to promote the sale, use or other dealings
# in this Software without prior written authorization from Stanford University.

import sys
import urllib2


def fix_auth_failure():
    """Fix the python 2.6.6 auth failure bug."""
    if sys.version_info[:2] == (2, 6) and sys.version_info[2] >= 6:
        def fixed_http_error_401(self, req, fp, code, msg, headers):

            url = req.get_full_url()
            response = self.http_error_auth_reqed('www-authenticate',
                                                  url, req, headers)
            self.retried = 0
            return response
        urllib2.HTTPBasicAuthHandler.http_error_401 = fixed_http_error_401

Add code to fix the python 2.6.6 auth failure issue.
Add code to fix the python 2.6.6 auth failure issue.


git-svn-id: 293778eaa97c8c94097d610b1bd5133a8f478f36@10708 4f837ed2-42f5-46e7-a7a5-fa17313484d4
