tst_http2::earlyResponse - fix a flaky and somewhat broken test
1. Fix erroneous logic, which was triggered in 'h2' mode (non-TLS connection) - after the initial protocol upgrade/POST request was handled, the server (on Windows specifically) was erroneously handling upcoming DATA frames by replying with another redirect response. 2. Make the test less heavy by sending 1 MB of Qt::Uninitialize instead of 10 MB - theoretically this could cause a timeout before the redirected request finished successfully. Task-number: QTBUG-73873 Change-Id: I961e0a5f50252988edd46d0e73baf96ee22eef3f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
10565c5ef3
commit
3a1a97dabe
@ -431,6 +431,13 @@ void Http2Server::readReady()
|
|||||||
if (connectionError)
|
if (connectionError)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (redirectSent) {
|
||||||
|
// We are a "single shot" server, working in 'h2' mode,
|
||||||
|
// responding with a redirect code. Don't bother to handle
|
||||||
|
// anything else now.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (upgradeProtocol) {
|
if (upgradeProtocol) {
|
||||||
handleProtocolUpgrade();
|
handleProtocolUpgrade();
|
||||||
} else if (waitingClientPreface) {
|
} else if (waitingClientPreface) {
|
||||||
@ -800,6 +807,13 @@ void Http2Server::sendResponse(quint32 streamID, bool emptyBody)
|
|||||||
|
|
||||||
HttpHeader header;
|
HttpHeader header;
|
||||||
if (redirectWhileReading) {
|
if (redirectWhileReading) {
|
||||||
|
if (redirectSent) {
|
||||||
|
// This is a "single-shot" server responding with a redirect code.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
redirectSent = true;
|
||||||
|
|
||||||
qDebug("server received HEADERS frame (followed by DATA frames), redirecting ...");
|
qDebug("server received HEADERS frame (followed by DATA frames), redirecting ...");
|
||||||
Q_ASSERT(targetPort);
|
Q_ASSERT(targetPort);
|
||||||
header.push_back({":status", "308"});
|
header.push_back({":status", "308"});
|
||||||
|
@ -193,6 +193,7 @@ private:
|
|||||||
// Redirect, with status code 308, as soon as we've seen headers, while client
|
// Redirect, with status code 308, as soon as we've seen headers, while client
|
||||||
// may still be sending DATA frames. See tst_Http2::earlyResponse().
|
// may still be sending DATA frames. See tst_Http2::earlyResponse().
|
||||||
bool redirectWhileReading = false;
|
bool redirectWhileReading = false;
|
||||||
|
bool redirectSent = false;
|
||||||
quint16 targetPort = 0;
|
quint16 targetPort = 0;
|
||||||
QAtomicInt interrupted;
|
QAtomicInt interrupted;
|
||||||
protected slots:
|
protected slots:
|
||||||
|
@ -473,7 +473,7 @@ void tst_Http2::earlyResponse()
|
|||||||
runEventLoop();
|
runEventLoop();
|
||||||
|
|
||||||
QVERIFY(serverPort);
|
QVERIFY(serverPort);
|
||||||
sendRequest(1, QNetworkRequest::NormalPriority, {10000000, Qt::Uninitialized});
|
sendRequest(1, QNetworkRequest::NormalPriority, {1000000, Qt::Uninitialized});
|
||||||
|
|
||||||
runEventLoop();
|
runEventLoop();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user