summaryrefslogtreecommitdiffstats
path: root/tests/auto/network
diff options
context:
space:
mode:
authorMårten Nordheim <morten242@gmail.com>2021-04-28 18:19:57 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2021-04-30 14:43:24 +0200
commitdeda40b8591a387e634ebfcf48287c14162ef332 (patch)
treef5a791fc717c548b518f97efd1b95e5781e0eff7 /tests/auto/network
parent000120d47c667254373441f5368861288df22423 (diff)
Let the h2 test server both send and receive DATA frames
And use this in the authenticationRequired test. Pick-to: 6.1 6.0 5.15 Change-Id: I18e991eb67168214c2c4f829afaca5018568e989 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'tests/auto/network')
-rw-r--r--tests/auto/network/access/http2/http2srv.cpp6
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp17
2 files changed, 17 insertions, 6 deletions
diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp
index c2670ca2a5..932b11fbb6 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 b38ebabe80..af3b6ba419 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -158,6 +158,7 @@ private:
int windowUpdates = 0;
bool prefaceOK = false;
bool serverGotSettingsACK = false;
+ bool POSTResponseHEADOnly = true;
static const RawSettings defaultServerSettings;
};
@@ -887,14 +888,21 @@ void tst_Http2::contentEncoding()
void tst_Http2::authenticationRequired_data()
{
QTest::addColumn<bool>("success");
-
- QTest::addRow("failed-auth") << false;
- QTest::addRow("successful-auth") << true;
+ QTest::addColumn<bool>("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);
@@ -973,6 +981,7 @@ void tst_Http2::clearHTTP2State()
windowUpdates = 0;
prefaceOK = false;
serverGotSettingsACK = false;
+ POSTResponseHEADOnly = true;
}
void tst_Http2::runEventLoop(int ms)
@@ -1105,7 +1114,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)