Author greatape
Recipients Dmitry.Jemerov, Jurjen, chuchiperriman, greatape, jonozzz, kiilerix, orsenthil, r.david.murray, zenyatta
Date 2011-01-20.22:31:34
SpamBayes Score 6.90677e-07
Marked as misclassified No
Message-id <>
I think there's a much simpler solution to this ticket than the retry logic that's currently in place.

The code originally avoided the infinite recursion by checking to see if the previous request had already submitted the auth credentials that would be used in the retry. If it had, it would return None. If it hadn't, it would add the auth credentials to the request header and the request again:

            if req.headers.get(self.auth_header, None) == auth:
                return None
            req.add_header(self.auth_header, auth)

Then, to fix #3819, it was changed. Instead of calling add_header, it called add_unredirected_header:

            if req.headers.get(self.auth_header, None) == auth:
                return None
            req.add_unredirected_header(self.auth_header, auth)

This caused the loop because the auth creds were going into unredirected_hdrs instead of the headers dict.

But I think the original logic is sound. The code just wasn't checking in all the headers. Luckily there's a get_header method that checks both for you. This one-line change should fix the issue:

            if req.get_header(self.auth_header, None) == auth:
                return None
            req.add_unredirected_header(self.auth_header, auth)

I think this fix is cleaner and makes more sense, but I'm worried I might be missing something. I don't fully understand the distinction between headers and unredirected headers. Maybe there's a reason why the code isn't checking in unredirected headers for the auth header.

I'm attaching a patch. I'm new to contributing to python so I apologize if the format is wrong.
Date User Action Args
2011-01-20 22:31:50greatapesetrecipients: + greatape, orsenthil, kiilerix, jonozzz, r.david.murray, Dmitry.Jemerov, chuchiperriman, Jurjen, zenyatta
2011-01-20 22:31:50greatapesetmessageid: <>
2011-01-20 22:31:34greatapelinkissue8797 messages
2011-01-20 22:31:34greatapecreate