diff options
Diffstat (limited to 'tests/auto/network/access/http2/http2srv.cpp')
-rw-r--r-- | tests/auto/network/access/http2/http2srv.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp index 9d68b5c798..9f77419461 100644 --- a/tests/auto/network/access/http2/http2srv.cpp +++ b/tests/auto/network/access/http2/http2srv.cpp @@ -41,6 +41,7 @@ #include <QtNetwork/qtcpsocket.h> +#include <QtCore/qtimer.h> #include <QtCore/qdebug.h> #include <QtCore/qlist.h> #include <QtCore/qfile.h> @@ -117,6 +118,13 @@ void Http2Server::setResponseBody(const QByteArray &body) responseBody = body; } +void Http2Server::emulateGOAWAY(int timeout) +{ + Q_ASSERT(timeout >= 0); + testingGOAWAY = true; + goawayTimeout = timeout; +} + void Http2Server::startServer() { #ifdef QT_NO_SSL @@ -271,6 +279,16 @@ void Http2Server::connectionEstablished() { using namespace Http2; + if (testingGOAWAY) { + auto timer = new QTimer(this); + timer->setSingleShot(true); + connect(timer, &QTimer::timeout, [this]() { + sendGOAWAY(quint32(connectionStreamID), quint32(INTERNAL_ERROR), 0); + }); + timer->start(goawayTimeout); + return; + } + connect(socket.data(), SIGNAL(readyRead()), this, SLOT(readReady())); |