checking invalid urls with ssl + python 2.1.3 on linux/windows

Josef Meile jmeile at hotmail.com
Tue Oct 12 08:12:41 EDT 2004


Hi,

I'm trying to do a simple link checking for python 2.1.3 (compiled from 
source on linux), but it fails when I use an invalid ssl url. For 
example: I have zope without ssl running on port 8080, if I do this on 
the browser's address bar:

https://my_ip:8080 --> The https is intentional

mozilla on linux and IE on windows, take a long time till a timeout 
occurs. I tried to check this timeout with the timeoutsocket.py (version 
1.23, the latest I could find) on linux, but it hangs:

import timeoutsocket
import smtplib
import urllib2

timeoutsocket.setDefaultSocketTimeout(5)
urllib2.urlopen('https://my_ip:8080')

Same happens with:

import httplib
import timeoutsocket
import smtplib

timeoutsocket.setDefaultSocketTimeout(5)
connection=httplib.HTTPSConnection('my_ip:8080')
connection.request('GET','/')

I searched on the newsgrous and found that timeoutsocket doesn't work 
with ssl sockets. So, I tried with signal alarms and the httplib and it 
succeeded on linux, but it doesn't work on windows because this os lacks 
of "signal.SIGALRM" :-(. I now about "socket.setdefaulttimeout", but 
this is a new feature and it doesn't exist on python 2.1.3 and I have to 
provide compatibility to this version (zope 2.6.x uses it).

Finally I found a message from Geoffrey Talvola, where he said that he 
has a patch which corrects this, but unfortunatelly I tried to contact 
him without any success. Does any body has such patch or perhaps a 
better idea of how to solve this problem?

Regards,
Josef



More information about the Python-list mailing list