'Connect directly over TCP for C{b\'http\'} scheme, and TLS for
C{b\'https\'}.
@param uri: L{URI} to connect to.
@return: Endpoint to connect to.
@rtype: L{IStreamClientEndpoint}'

def endpointForURI(self, uri):

    kwargs = {}
    if (self._connectTimeout is not None):
        kwargs['timeout'] = self._connectTimeout
    kwargs['bindAddress'] = self._bindAddress
    try:
        host = nativeString(uri.host)
    except UnicodeDecodeError:
        raise ValueError('The    host    of    the    provided    URI    ({uri.host!r})    contains    non-ASCII    octets,    it    should    be    ASCII    decodable.'.format(uri=uri))
    endpoint = HostnameEndpoint(self._reactor, host, uri.port, **kwargs)
    if (uri.scheme == 'http'):
        return endpoint
    elif (uri.scheme == 'https'):
        connectionCreator = self._policyForHTTPS.creatorForNetloc(uri.host, uri.port)
        return wrapClientTLS(connectionCreator, endpoint)
    else:
        raise SchemeNotSupported(('Unsupported    scheme:    %r' % (uri.scheme,)))
