python/cpython — pull request #5 by mcepl (2014-08-11 10:37:06+00:00)
Title: Alternative handler adding Authorization header even in the first request

Add new HTTPBasicPriorAuthHandler which adds the Authorization header with the authentication code even to the first HTTP request not only as the reaction to the failed attempt to connect as the default
HTTPBasicAuthHandler does.

Allows working with websites like https://api.github.com which do not
follow the strict interpretation of RFC, but more the dicta in the end
of section 2 of RFC 2617:

> A client MAY preemptively send the corresponding Authorization
> header with requests for resources in that space without receipt
> of another challenge from the server. Similarly, when a client
> sends a request to a proxy, it may reuse a userid and password in
> the Proxy-Authorization header field without receiving another
> challenge from the proxy server. See section 4 for security
> considerations associated with Basic authentication.

Fixes issue 19494.

Signed-off-by: Matěj Cepl