urllib, python 1.52, basic authentication

Ari Davidow ari at ivritype.com
Thu Apr 19 13:05:25 EDT 2001


Sheesh. Indeed, it appears to have been just that simple.

Many, many thanks,
ari

At 08:29 AM 4/19/2001 +0200, you wrote:
>Ari Davidow wrote:
>> I am trying to request a page that is being protected by basic 
>authentication.
>> 
>> import httplib, urllib,binascii
>> cookie = binascii.b2a_base64("user:password")
>> h = httplib.HTTP("www.site.com")
>> h.putrequest("GET", "/admin/flushgo.html?ok=ok" "HTTP/1.0\r\n")
>
>
>I think you can (and should) omit that HTTP/1.0 specifier and the line ending.
>
>       h.putrequest("GET", "/admin/flushgo.html?ok=ok")
>
>
>> h.putheader("Proxy-authorization", "Basic %s" % cookie)
>
>
>And here, according to the source of urllib2.py, this should be changed to:
>
>       h.putheader("Authorization", "Basic %s" % cookie)
>
>Good luck,
>
>-Steve
>
>
>-- 
>Steve Purcell, Pythangelist
>Get testing at http://pyunit.sourceforge.net/
>Any opinions expressed herein are my own and not necessarily those of Yahoo
>
>-- 
>http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list