[Tutor] urllib2 issue getting realm

Johan Geldenhuys johan at accesstel.com.au
Wed Aug 31 14:27:33 CEST 2011

Focusing on the code below, do you know why it would raise the exception for the first IP and not for the second?

Thank you
Sent from my iPhone 4

On 31/08/2011, at 22:09, Sander Sweers <sander.sweers at gmail.com> wrote:

> 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
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list