~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_pycurl.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-08 17:37:09 UTC
  • mfrom: (3928.1.1 bzr.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090108173709-wgrkm02ayt1gf1n1
(vila) Add native ssl support for python-2.6,
        starting with an https test server

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
    """
87
87
    return pycurl.__dict__.get(symbol, default)
88
88
 
89
 
CURLE_SSL_CACERT_BADFILE = _get_pycurl_errcode('E_SSL_CACERT_BADFILE', 77)
90
89
CURLE_COULDNT_CONNECT = _get_pycurl_errcode('E_COULDNT_CONNECT', 7)
91
90
CURLE_COULDNT_RESOLVE_HOST = _get_pycurl_errcode('E_COULDNT_RESOLVE_HOST', 6)
92
91
CURLE_COULDNT_RESOLVE_PROXY = _get_pycurl_errcode('E_COULDNT_RESOLVE_PROXY', 5)
93
92
CURLE_GOT_NOTHING = _get_pycurl_errcode('E_GOT_NOTHING', 52)
94
93
CURLE_PARTIAL_FILE = _get_pycurl_errcode('E_PARTIAL_FILE', 18)
95
94
CURLE_SEND_ERROR = _get_pycurl_errcode('E_SEND_ERROR', 55)
 
95
CURLE_SSL_CACERT = _get_pycurl_errcode('E_SSL_CACERT', 60)
 
96
CURLE_SSL_CACERT_BADFILE = _get_pycurl_errcode('E_SSL_CACERT_BADFILE', 77)
96
97
 
97
98
 
98
99
class PyCurlTransport(HttpTransportBase):
343
344
            url = curl.getinfo(pycurl.EFFECTIVE_URL)
344
345
            mutter('got pycurl error: %s, %s, %s, url: %s ',
345
346
                    e[0], e[1], e, url)
346
 
            if e[0] in (CURLE_SSL_CACERT_BADFILE,
347
 
                        CURLE_COULDNT_RESOLVE_HOST,
 
347
            if e[0] in (CURLE_COULDNT_RESOLVE_HOST,
 
348
                        CURLE_COULDNT_RESOLVE_PROXY,
348
349
                        CURLE_COULDNT_CONNECT,
349
350
                        CURLE_GOT_NOTHING,
350
 
                        CURLE_COULDNT_RESOLVE_PROXY,):
 
351
                        CURLE_SSL_CACERT,
 
352
                        CURLE_SSL_CACERT_BADFILE,
 
353
                        ):
351
354
                raise errors.ConnectionError(
352
355
                    'curl connection error (%s)\non %s' % (e[1], url))
353
356
            elif e[0] == CURLE_PARTIAL_FILE:
371
374
 
372
375
def get_test_permutations():
373
376
    """Return the permutations to be used in testing."""
374
 
    from bzrlib.tests.http_server import HttpServer_PyCurl
375
 
    return [(PyCurlTransport, HttpServer_PyCurl),
376
 
            ]
 
377
    from bzrlib import tests
 
378
    from bzrlib.tests import http_server
 
379
    permutations = [(PyCurlTransport, http_server.HttpServer_PyCurl),]
 
380
    if tests.HTTPSServerFeature.available():
 
381
        from bzrlib.tests import (
 
382
            https_server,
 
383
            ssl_certs,
 
384
            )
 
385
 
 
386
        class HTTPS_pycurl_transport(PyCurlTransport):
 
387
 
 
388
            def __init__(self, base, _from_transport=None):
 
389
                super(HTTPS_pycurl_transport, self).__init__(base,
 
390
                                                             _from_transport)
 
391
                self.cabundle = str(ssl_certs.build_path('ca.crt'))
 
392
 
 
393
        permutations.append((HTTPS_pycurl_transport,
 
394
                             https_server.HTTPSServer_PyCurl))
 
395
    return permutations