'Issue C{request} over C{self.transport} and return a L{Deferred} which
will fire with a L{Response} instance or an error.
@param request: The object defining the parameters of the request to
issue.
@type request: L{Request}
@rtype: L{Deferred}
@return: The deferred may errback with L{RequestGenerationFailed} if
the request was not fully written to the transport due to a local
error.  It may errback with L{RequestTransmissionFailed} if it was
not fully written to the transport due to a network error.  It may
errback with L{ResponseFailed} if the request was sent (not
necessarily received) but some or all of the response was lost.  It
may errback with L{RequestNotSent} if it is not possible to send
any more requests using this L{HTTP11ClientProtocol}.'

def request(self, request):

    if (self._state != 'QUIESCENT'):
        return fail(RequestNotSent())
    self._state = 'TRANSMITTING'
    _requestDeferred = maybeDeferred(request.writeTo, self.transport)
    def cancelRequest(ign):
        if (self._state in ('TRANSMITTING', 'TRANSMITTING_AFTER_RECEIVING_RESPONSE')):
            _requestDeferred.cancel()
        else:
            self.transport.abortConnection()
            self._disconnectParser(Failure(CancelledError()))
    self._finishedRequest = Deferred(cancelRequest)
    self._currentRequest = request
    self._transportProxy = TransportProxyProducer(self.transport)
    self._parser = HTTPClientParser(request, self._finishResponse)
    self._parser.makeConnection(self._transportProxy)
    self._responseDeferred = self._parser._responseDeferred
    def cbRequestWritten(ignored):
        if (self._state == 'TRANSMITTING'):
            self._state = 'WAITING'
            self._responseDeferred.chainDeferred(self._finishedRequest)
    def ebRequestWriting(err):
        if (self._state == 'TRANSMITTING'):
            self._state = 'GENERATION_FAILED'
            self.transport.abortConnection()
            self._finishedRequest.errback(Failure(RequestGenerationFailed([err])))
        else:
            log.err(err, (u'Error    writing    request,    but    not    in    valid    state    to    finalize    request:    %s' % self._state))
    _requestDeferred.addCallbacks(cbRequestWritten, ebRequestWriting)
    return self._finishedRequest
