HTTP - basic authentication example.

Michael Foord fuzzyman at
Wed Sep 22 16:56:29 CEST 2004

jjl at (John J. Lee) wrote in message news:<87isabn06u.fsf at>...
> fuzzyman at (Michael Foord) writes:
> > Jaime Wyant < at> wrote in message news:<mailman.3402.1095338985.5135.python-list at>...
>  [...]
> > have found it in your docs). This means I have a ClientCookie handler
> > handling all my http requests.... I wonder if I can use an AuthHandler
> > as well ? There will be situations where I am likely to want to add an
> > Authroize header *and* handle cookies - ClientCookie manages all the
> > cookies in a way that I couldn't do manually.
> Sure, cookielib.HTTPCookieProcessor (or
> ClientCookie.HTTPCookieProcessor) should work fine with all other
> urllib2 handlers.  Cookies and Basic HTTP Authentication are quite
> distinct and separate in their implementation at the HTTP level.

Really ? I can see situations where they both have to handle a
request.... but then I guess all cookielib has to do is add the
appropriate cookie header and then pass the request down the chain ?

(all is not meant as a denigration - merely a description ;-)


> [...]
> > The example you gave works I think - HTTPBasicAuthHandler does have an
> > add_password method, but not the find_user_password that the
> > HTTPPasswordMgr has... so I can't easily check if it works properly.
> > In the urllib2 docs it says that passing a password manager in is
> > optional - but *nowhere* does it document that it has an add_password
> > method. It may be deducable from the fact that passing in a password
> > manager is optional - but surely explicit is better than implicit
> > (especially where documentation is concerned).
> [...]
> Tested doc patches posted to the Python patch tracker are
> welcome :-)

Hmm... maybe.
I only know what I've deduced and I'm not over confident that it's
100% cast iron right - I just think it's probably right.

I'm quite happy to submit it - but if it's innacurate I don't do the
python community or myself any favours.........



> John

More information about the Python-list mailing list