Issue 1497027: urllib2: ensure digest auth happens in preference to basic (original) (raw)
At the moment in urllib2, digest auth is only tried before basic (as MUST happen according to RFC 2617 section 1.2) only if .add_handler() was called for HTTPDigestAuthHandler before HTTPBasicAuthHandler. This patch ensures that digest is always tried first.
I guess it's unfortunate that sorting of handlers is done by an attribute rather than by declaring and using topological sort, since any change to a handler_order may break code, but that can only be fixed by adding that as a new feature (probably a new factory). I doubt this particular change will catch anybody out, and it can violate the RFC as-is, so I think this should go in. The patch removes the note in the docs about current values of handler_orders, since that was already out of date even before this patch.