def _responseFromMessage(self, message, rCode=dns.OK,
                             answers=None, authority=None, additional=None):
        """
        Generate a L{Message} instance suitable for use as the response to
        C{message}.

        C{queries} will be copied from the request to the response.

        C{rCode}, C{answers}, C{authority} and C{additional} will be assigned to
        the response, if supplied.

        The C{recAv} flag will be set on the response if the C{canRecurse} flag
        on this L{DNSServerFactory} is set to L{True}.

        The C{auth} flag will be set on the response if *any* of the supplied
        C{answers} have their C{auth} flag set to L{True}.

        The response will have the same C{maxSize} as the request.

        Additionally, the response will have a C{timeReceived} attribute whose
        value is that of the original request and the

        @see: L{dns._responseFromMessage}

        @param message: The request message
        @type message: L{Message}

        @param rCode: The response code which will be assigned to the response.
        @type message: L{int}

        @param answers: An optional list of answer records which will be
            assigned to the response.
        @type answers: L{list} of L{dns.RRHeader}

        @param authority: An optional list of authority records which will be
            assigned to the response.
        @type authority: L{list} of L{dns.RRHeader}

        @param additional: An optional list of additional records which will be
            assigned to the response.
        @type additional: L{list} of L{dns.RRHeader}

        @return: A response L{Message} instance.
        @rtype: L{Message}
        """
        if answers is None:
            answers = []
        if authority is None:
            authority = []
        if additional is None:
            additional = []
        authoritativeAnswer = False
        for x in answers:
            if x.isAuthoritative():
                authoritativeAnswer = True
                break

        response = dns._responseFromMessage(
            responseConstructor=self._messageFactory,
            message=message,
            recAv=self.canRecurse,
            rCode=rCode,
            auth=authoritativeAnswer
        )

        # XXX: Timereceived is a hack which probably shouldn't be tacked onto
        # the message. Use getattr here so that we don't have to set the
        # timereceived on every message in the tests. See #6957.
        response.timeReceived = getattr(message, 'timeReceived', None)

        # XXX: This is another hack. dns.Message.decode sets maxSize=0 which
        # means that responses are never truncated. I'll maintain that behaviour
        # here until #6949 is resolved.
        response.maxSize = message.maxSize

        response.answers = answers
        response.authority = authority
        response.additional = additional

        return response

        Generate a L{Message} instance suitable for use as the response to
        C{message}.

        C{queries} will be copied from the request to the response.

        C{rCode}, C{answers}, C{authority} and C{additional} will be assigned to
        the response, if supplied.

        The C{recAv} flag will be set on the response if the C{canRecurse} flag
        on this L{DNSServerFactory} is set to L{True}.

        The C{auth} flag will be set on the response if *any* of the supplied
        C{answers} have their C{auth} flag set to L{True}.

        The response will have the same C{maxSize} as the request.

        Additionally, the response will have a C{timeReceived} attribute whose
        value is that of the original request and the

        @see: L{dns._responseFromMessage}

        @param message: The request message
        @type message: L{Message}

        @param rCode: The response code which will be assigned to the response.
        @type message: L{int}

        @param answers: An optional list of answer records which will be
            assigned to the response.
        @type answers: L{list} of L{dns.RRHeader}

        @param authority: An optional list of authority records which will be
            assigned to the response.
        @type authority: L{list} of L{dns.RRHeader}

        @param additional: An optional list of additional records which will be
            assigned to the response.
        @type additional: L{list} of L{dns.RRHeader}

        @return: A response L{Message} instance.
        @rtype: L{Message}
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/names/server.py