def dataReceived(self, data):
        """
        An override of L{IProtocol.dataReceived} that checks what protocol we're
        using.
        """
        if self._negotiatedProtocol is None:
            try:
                negotiatedProtocol = self._channel.transport.negotiatedProtocol
            except AttributeError:
                # Plaintext HTTP, always HTTP/1.1
                negotiatedProtocol = b'http/1.1'

            if negotiatedProtocol is None:
                negotiatedProtocol = b'http/1.1'

            if negotiatedProtocol == b'h2':
                if not H2_ENABLED:
                    raise ValueError("Negotiated HTTP/2 without support.")

                # We need to make sure that the HTTPChannel is unregistered
                # from the transport so that the H2Connection can register
                # itself if possible.
                self._channel._networkProducer.unregisterProducer()

                transport = self._channel.transport
                self._channel = H2Connection()
                self._channel.requestFactory = self._requestFactory
                self._channel.site = self._site
                self._channel.factory = self._factory
                self._channel.timeOut = self._timeOut
                self._channel.callLater = self._callLater
                self._channel.makeConnection(transport)
            else:
                # Only HTTP/2 and HTTP/1.1 are supported right now.
                assert negotiatedProtocol == b'http/1.1', \
                       "Unsupported protocol negotiated"

            self._negotiatedProtocol = negotiatedProtocol

        return self._channel.dataReceived(data)

        An override of L{IProtocol.dataReceived} that checks what protocol we're
        using.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/http.py