diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp index 38b219ed175..0bad7481715 100644 --- a/src/network/access/qhttp2connection.cpp +++ b/src/network/access/qhttp2connection.cpp @@ -910,8 +910,13 @@ void QHttp2Connection::handleHEADERS() if (streamID == connectionStreamID) return connectionError(PROTOCOL_ERROR, "HEADERS on 0x0 stream"); - if (streamID > m_lastIncomingStreamID) { + const bool isClient = m_connectionType == Type::Client; + const bool isClientInitiatedStream = !!(streamID & 1); + const bool isRemotelyInitiatedStream = isClient ^ isClientInitiatedStream; + + if (isRemotelyInitiatedStream && streamID > m_lastIncomingStreamID) { QHttp2Stream *newStream = createStreamInternal_impl(streamID); + Q_ASSERT(newStream); m_lastIncomingStreamID = streamID; qCDebug(qHttp2ConnectionLog, "[%p] Created new incoming stream %d", this, streamID); emit newIncomingStream(newStream); diff --git a/tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp b/tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp index d9641c7391d..cfb51b0e300 100644 --- a/tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp +++ b/tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp @@ -266,6 +266,7 @@ void tst_QHttp2Connection::connectToServer() QVERIFY(waitForSettingsExchange(connection, serverConnection)); QSignalSpy newIncomingStreamSpy{ serverConnection, &QHttp2Connection::newIncomingStream }; + QSignalSpy clientIncomingStreamSpy{ connection, &QHttp2Connection::newIncomingStream }; QHttp2Stream *clientStream = connection->createStream().unwrap(); QSignalSpy clientHeaderReceivedSpy{ clientStream, &QHttp2Stream::headersReceived }; @@ -283,6 +284,8 @@ void tst_QHttp2Connection::connectToServer() const HPack::HttpHeader headersReceived = clientHeaderReceivedSpy.front().front().value(); QCOMPARE(headersReceived, ExpectedResponseHeaders); + + QCOMPARE(clientIncomingStreamSpy.count(), 0); } void tst_QHttp2Connection::WINDOW_UPDATE()