'Processes the response from the proxy. If the tunnel is successfully
created, notifies the client that we are ready to send requests. If not
raises a TunnelError.'

def processProxyResponse(self, rcvd_bytes):

    self._connectBuffer += rcvd_bytes
    if ('\r\n\r\n' not in self._connectBuffer):
        return
    self._protocol.dataReceived = self._protocolDataReceived
    respm = TunnelingTCP4ClientEndpoint._responseMatcher.match(self._connectBuffer)
    if (respm and (int(respm.group('status')) == 200)):
        try:
            sslOptions = self._contextFactory.creatorForNetloc(self._tunneledHost, self._tunneledPort)
        except AttributeError:
            sslOptions = self._contextFactory
        self._protocol.transport.startTLS(sslOptions, self._protocolFactory)
        self._tunnelReadyDeferred.callback(self._protocol)
    else:
        if respm:
            extra = {'status': int(respm.group('status')), 'reason': respm.group('reason').strip()}
        else:
            extra = rcvd_bytes[:32]
        self._tunnelReadyDeferred.errback(TunnelError(('Could    not    open    CONNECT    tunnel    with    proxy    %s:%s    [%r]' % (self._host, self._port, extra))))
