def _requestWithEndpoint(self, key, endpoint, method, parsedURI,
                             headers, bodyProducer, requestPath):
        """
        Issue a new request, given the endpoint and the path sent as part of
        the request.
        """
        if not isinstance(method, bytes):
            raise TypeError('method={!r} is {}, but must be bytes'.format(
                    method, type(method)))

        method = _ensureValidMethod(method)

        # Create minimal headers, if necessary:
        if headers is None:
            headers = Headers()
        if not headers.hasHeader(b'host'):
            headers = headers.copy()
            headers.addRawHeader(
                b'host', self._computeHostValue(parsedURI.scheme,
                                                parsedURI.host,
                                                parsedURI.port))

        d = self._pool.getConnection(key, endpoint)
        def cbConnected(proto):
            return proto.request(
                Request._construct(method, requestPath, headers, bodyProducer,
                                   persistent=self._pool.persistent,
                                   parsedURI=parsedURI))
        d.addCallback(cbConnected)
        return d

        Issue a new request, given the endpoint and the path sent as part of
        the request.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/client.py