Marcelo Fernández <fernandez...@yahoo.com.ar> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue3466>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to