Message86828
The workaround I posted before doesn't work with Python 2.6. This one
works (at least) with Python 2.5 *and* Python 2.6:
import httplib
import urllib2
key_file = 'mykey.pem'
cert_file = 'mycert-signed.pem'
class HTTPSClientAuthConnection(httplib.HTTPSConnection):
def __init__(self, host, timeout=None):
httplib.HTTPSConnection.__init__(self, host, key_file=key_file,
cert_file=cert_file)
self.timeout = timeout # Only valid in Python 2.6
class HTTPSClientAuthHandler(urllib2.HTTPSHandler):
def https_open(self, req):
return self.do_open(HTTPSClientAuthConnection, req)
This is a little class to use it:
class Connection(object):
def __init__(self, url):
# TODO: Validate/Sanitize the url
self.url = url
self._cookiejar = cookielib.CookieJar()
def send(self, **data):
parameters = urllib.urlencode(data)
opener =
urllib2.build_opener(HTTPHandler(debuglevel=DEBUG_LEVEL),
HTTPSClientAuthHandler(debuglevel=DEBUG_LEVEL),
HTTPCookieProcessor(self._cookiejar))
req = Request(self.url, parameters)
server_response = opener.open(req).read()
print server_response
return server_response
Regards |
|
Date |
User |
Action |
Args |
2009-04-29 22:07:05 | marcelo_fernandez | set | recipients:
+ marcelo_fernandez, jjlee, orsenthil |
2009-04-29 22:07:04 | marcelo_fernandez | set | messageid: <1241042824.9.0.796322780597.issue3466@psf.upfronthosting.co.za> |
2009-04-29 22:07:03 | marcelo_fernandez | link | issue3466 messages |
2009-04-29 22:07:02 | marcelo_fernandez | create | |
|