'Issue a request to the server indicated by the given C{uri}.
An existing connection from the connection pool may be used or a new
one may be created.
I{HTTP} and I{HTTPS} schemes are supported in C{uri}.
@see: L{twisted.web.iweb.IAgent.request}'

def request(self, method, uri, headers=None, bodyProducer=None):

    parsedURI = URI.fromBytes(uri)
    try:
        endpoint = self._getEndpoint(parsedURI)
    except SchemeNotSupported:
        return defer.fail(Failure())
    key = (parsedURI.scheme, parsedURI.host, parsedURI.port)
    return self._requestWithEndpoint(key, endpoint, method, parsedURI, headers, bodyProducer, parsedURI.originForm)
