[Tutor] urllib2 issue getting realm
Sander Sweers
sander.sweers at gmail.com
Wed Aug 31 14:09:14 CEST 2011
On 31 August 2011 09:46, Johan Geldenhuys <johan at accesstel.com.au> wrote:
> I am trying to use a very simple piece of code to get the realm from
> different HTTPS URLs.
>
> This realm is essential for successful authentication on the HTTPS session.
I think you got 2 things mixed up, http authentication and encrypted
http (https). Just having a https url does not mean you need to
authenticate. Take 'https://mail.google.com' as an example.
> If have to run this for a few different hosts and capture the realm.
> For one host, it works perfectly, but when I try the same code to get the
> next realm, it fails. I suspect that I need to close some type of
> connections or something, but I can't put my finger on it.
<snip>
> For the next one:
>
>>>> try:
> ... req = urllib2.Request(URL % ips[1])
> ... handle = urllib2.urlopen(req)
> ... except IOError, e:
> ... print `e`
> ...
>>>>
>
> See, no "e" printed which means that something worked. The exception didn't
> happen and I don't know why...Anybody?
Yes, when you type the url into your browser. I suspect it does not
ask you to authenticate via http authentication. Therefor no exception
is raised and you never print the headers.
Greets
Sander
More information about the Tutor
mailing list