def _process(self):
        if not self._requests:
            # Stop processing and close any connection since we've not got any
            # requests left.
            if self._stream:
                self._want_close = True
                self._no_process = True
                self._stream.close(False)
                self._stream = None
            self._processing = False
            return
        self._processing = True

        # Get the request.
        request = self._requests[0]

        # Make sure it has a response.
        if not request.response:
            HTTPResponse(request)

        # Handle authentication.
        if request.auth and not isinstance(request.auth, (list,tuple)):
            request = request.auth(request)

        # Now, determine what we should be connected to.
        port = _port(request.url)
        is_secure = request.url.scheme == 'https'
        if not port:
            port = 443 if is_secure else 80
        host = '%s:%d' % (_hostname(request.url), port)

        # If we have a stream, and it's not connected to that host, kill it
        # to make a new one.
        if self._stream:
            if not self._stream.connected:
                self._stream = None
            elif self._ssl_options != request.session.ssl_options or \
                    not self._stream.can_fetch(host, is_secure):
                log.debug("Closing unusable stream for %r." % self)
                self._want_close = True
                self._no_process = False
                self._stream.close(False)
                return

        # Set the timeout timer and log.
        log.debug("Sending HTTP request %r." % request)
        self._reset_timer()

        # Create a stream.
        if not self._stream:
            self._stream = _HTTPStream(self, engine=self.engine)

        # If we're secure, and the stream isn't, secure it.
        if is_secure and not self._stream.ssl_enabled:
            self._ssl_options = request.session.ssl_options
            self._stream.startSSL(self._ssl_options or {})

        # Connect the stream to await further orders.
        self._stream.connect((_hostname(request.url), port))
Send the first request on the stack.
dataset/ETHPy150Open ecdavis/pants/pants/http/client.py/HTTPClient._process