def handler(key_file=None, cert_file=None, timeout=None):
    """This class returns an instance of the default HTTP request handler using
    the values you provide.

    :param `key_file`: A path to a PEM (Privacy Enhanced Mail) formatted file containing your private key (optional).
    :type key_file: ``string``
    :param `cert_file`: A path to a PEM (Privacy Enhanced Mail) formatted file containing a certificate chain file (optional).
    :type cert_file: ``string``
    :param `timeout`: The request time-out period, in seconds (optional).
    :type timeout: ``integer`` or "None"
    """

    def connect(scheme, host, port):
        kwargs = {}
        if timeout is not None: kwargs['timeout'] = timeout
        if scheme == "http":
            return httplib.HTTPConnection(host, port, **kwargs)
        if scheme == "https":
            if key_file is not None: kwargs['key_file'] = key_file
            if cert_file is not None: kwargs['cert_file'] = cert_file
            return httplib.HTTPSConnection(host, port, **kwargs)
        raise ValueError("unsupported scheme: %s" % scheme)

    def request(url, message, **kwargs):
        scheme, host, port, path = _spliturl(url)
        body = message.get("body", "")
        head = {
            "Content-Length": str(len(body)),
            "Host": host,
            "User-Agent": "splunk-sdk-python/0.1",
            "Accept": "*/*",
        } # defaults
        for key, value in message["headers"]:
            head[key] = value
        method = message.get("method", "GET")

        connection = connect(scheme, host, port)
        try:
            connection.request(method, path, body, head)
            if timeout is not None:
                connection.sock.settimeout(timeout)
            response = connection.getresponse()
        finally:
            connection.close()

        return {
            "status": response.status,
            "reason": response.reason,
            "headers": response.getheaders(),
            "body": ResponseReader(response),
        }

    return request
def handler ( key_file = None , cert_file = None , timeout = None ) : def connect ( scheme , host , port ) : kwargs = { } if timeout is not None : kwargs [ 'timeout' ] = timeout if scheme == "http" : return httplib . HTTPConnection ( host , port , ** kwargs ) if scheme == "https" : if key_file is not None : kwargs [ 'key_file' ] = key_file if cert_file is not None : kwargs [ 'cert_file' ] = cert_file return httplib . HTTPSConnection ( host , port , ** kwargs ) raise ValueError ( "unsupported scheme: %s" % scheme ) def request ( url , message , ** kwargs ) : scheme , host , port , path = _spliturl ( url ) body = message . get ( "body" , "" ) head = { "Content-Length" : str ( len ( body ) ) , "Host" : host , "User-Agent" : "splunk-sdk-python/0.1" , "Accept" : "*/*" , } for key , value in message [ "headers" ] : head [ key ] = value method = message . get ( "method" , "GET" ) connection = connect ( scheme , host , port ) try : connection . request ( method , path , body , head ) if timeout is not None : connection . sock . settimeout ( timeout ) response = connection . getresponse ( ) finally : connection . close ( ) return { "status" : response . status , "reason" : response . reason , "headers" : response . getheaders ( ) , "body" : ResponseReader ( response ) , } return request
This class returns an instance of the default HTTP request handler using
    the values you provide.

    :param `key_file`: A path to a PEM (Privacy Enhanced Mail) formatted file containing your private key (optional).
    :type key_file: ``string``
    :param `cert_file`: A path to a PEM (Privacy Enhanced Mail) formatted file containing a certificate chain file (optional).
    :type cert_file: ``string``
    :param `timeout`: The request time-out period, in seconds (optional).
    :type timeout: ``integer`` or "None"