def _handle_message(self, message, buffer, record_fn):
        """Build a response calling record_fn on all the TlsRecords in message

        message: bytes to parse as TlsRecords
        record_fn: one of on_tls_request, on_tls_response to handle the record
        Returns tuple containing the bytes to send for all the records handled and any remaining unparsed data
        """
        out = ""
        message = buffer.buffer + message
        buffer.buffer = ""
        remaining = message
        while remaining:
            record = None
            try:
                record, remaining = tls.parse_tls(remaining, throw_on_incomplete=True)
            except tls.types.TlsNotEnoughDataError:
                if buffer.should_buffer:
                    buffer.buffer = remaining
                    if len(buffer.buffer) >= buffer.MAX_BUFFER:
                        buffer.buffer = ""
                return out
            if not record:
                return out
            record_bytes = record_fn(record)
            # In a passive handler on_tls_* could return None, so make sure not to cause an error
            # out doesn't matter on a passive handler.
            if record_bytes:
                out += record_bytes
            # Once we read a CHANGE_CIPHER_SPEC stop trying to buffer, its probably encrypted
            if record.content_type == record.CONTENT_TYPE.CHANGE_CIPHER_SPEC:
                buffer.should_buffer = False
        return out
Build a response calling record_fn on all the TlsRecords in message

        message: bytes to parse as TlsRecords
        record_fn: one of on_tls_request, on_tls_response to handle the record
        Returns tuple containing the bytes to send for all the records handled and any remaining unparsed data
        
nogotofail/mitm/connection/handlers/data/ssl.py