From 8a8e3a501a84a319a1aa5e240ea6e0e9e8511006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 28 Apr 2021 18:19:57 +0200 Subject: Let the h2 test server both send and receive DATA frames And use this in the authenticationRequired test. Change-Id: I18e991eb67168214c2c4f829afaca5018568e989 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov (cherry picked from commit deda40b8591a387e634ebfcf48287c14162ef332) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/network/access/http2/http2srv.cpp | 6 ++++-- tests/auto/network/access/http2/tst_http2.cpp | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp index dfd0a69327..a4b3508f29 100644 --- a/tests/auto/network/access/http2/http2srv.cpp +++ b/tests/auto/network/access/http2/http2srv.cpp @@ -753,8 +753,10 @@ void Http2Server::handleDATA() } if (inboundFrame.flags().testFlag(FrameFlag::END_STREAM)) { - closedStreams.insert(streamID); // Enter "half-closed remote" state. - streamWindows.erase(it); + if (responseBody.isEmpty()) { + closedStreams.insert(streamID); // Enter "half-closed remote" state. + streamWindows.erase(it); + } emit receivedData(streamID); } emit receivedDATAFrame(streamID, diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index 29121581f8..7a2a1db113 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -160,6 +160,7 @@ private: int windowUpdates = 0; bool prefaceOK = false; bool serverGotSettingsACK = false; + bool POSTResponseHEADOnly = true; static const RawSettings defaultServerSettings; }; @@ -889,14 +890,21 @@ void tst_Http2::contentEncoding() void tst_Http2::authenticationRequired_data() { QTest::addColumn("success"); - - QTest::addRow("failed-auth") << false; - QTest::addRow("successful-auth") << true; + QTest::addColumn("responseHEADOnly"); + + QTest::addRow("failed-auth") << false << true; + QTest::addRow("successful-auth") << true << true; + // Include a DATA frame in the response from the remote server. An example would be receiving a + // JSON response on a request along with the 401 error. + QTest::addRow("failed-auth-with-response") << false << false; + QTest::addRow("successful-auth-with-response") << true << false; } void tst_Http2::authenticationRequired() { clearHTTP2State(); + QFETCH(const bool, responseHEADOnly); + POSTResponseHEADOnly = responseHEADOnly; QFETCH(const bool, success); @@ -975,6 +983,7 @@ void tst_Http2::clearHTTP2State() windowUpdates = 0; prefaceOK = false; serverGotSettingsACK = false; + POSTResponseHEADOnly = true; } void tst_Http2::runEventLoop(int ms) @@ -1107,7 +1116,7 @@ void tst_Http2::receivedData(quint32 streamID) Q_ASSERT(srv); QMetaObject::invokeMethod(srv, "sendResponse", Qt::QueuedConnection, Q_ARG(quint32, streamID), - Q_ARG(bool, true /*HEADERS only*/)); + Q_ARG(bool, POSTResponseHEADOnly /*true = HEADERS only*/)); } void tst_Http2::windowUpdated(quint32 streamID) -- cgit v1.2.3