On Wed, Jun 30, 2010 at 5:04 PM, Michael Hanselmann <[email protected]> wrote:
> Currently the RAPI client uses the urllib2 and httplib modules from
> Python's standard library. They're used with pyOpenSSL in a very
> fragile way, and there are known issues when receiving large
> responses from a RAPI server.
>
> By switching to PycURL we leverage the power and stability of the
> widely-used curl library (libcurl). This brings us much more
> flexibility than before, and timeouts were easily implemented
> (something that would have involved a lot of work with the built-in
> modules).
>
> There's one small drawback: Programs using libcurl have to call
> curl_global_init(3) (available as pycurl.global_init) when only
> one thread is running and are supposed to call
> curl_global_cleanup(3) (available as pycurl.global_cleanup) upon
> exiting. A decorator is provided to simplify this.
>
> Unittests for the new code are provided, increasing the test coverage
> of the RAPI client from 74% to 89%.
>
> Signed-off-by: Michael Hanselmann <[email protected]>

LGTM, one comment below:

> +    logger.debug("Using cURL version %s", pycurl.version)
> +
> +    sslver = _pycurl_version_fn()[5]
> +    if not sslver:
> +      raise Error("No SSL support in cURL")
> +
> +    lcsslver = sslver.lower()
> +    if lcsslver.startswith("openssl/"):
> +      pass
> +    elif lcsslver.startswith("gnutls/"):

For later logging and for ease of checking at other times, I think we
should extract this code to a helper function, and save the ssl
library type and version somewhere if possible.

> +      if capath:
> +        raise Error("cURL linked against GnuTLS has no support for a"
> +                    " CA path (%s)" % (pycurl.version, ))

And then extract this out of the previous if.

Thanks,

Guido

Reply via email to