HTTP - basic authentication example.

Michael Foord fuzzyman at gmail.com
Wed Sep 22 10:56:29 EDT 2004


jjl at pobox.com (John J. Lee) wrote in message news:<87isabn06u.fsf at pobox.com>...
> fuzzyman at gmail.com (Michael Foord) writes:
> > Jaime Wyant <programmer.py at gmail.com> wrote in message news:<mailman.3402.1095338985.5135.python-list at python.org>...
>  [...]
> > 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 ;-)

[snip..]

> 
> [...]
> > 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 sf.net 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.........

Regards,

Fuzzy
http://www.voidspace.org.uk/atlantibots/pythonutils.html

> 
> John



More information about the Python-list mailing list