summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/network/access/qnetworkreply
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@blackberry.com>2014-01-22 14:54:21 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-19 21:44:15 +0100
commit1de244ea65f1b40c488fe92b29170c1b1d447233 (patch)
treea01d233e33847cf8709b6130ad7fa4656ff348de /tests/benchmarks/network/access/qnetworkreply
parent42789d04a3078652594b8e06f520d7dd5e8021c5 (diff)
network: add support for the SPDY protocol
Currently the only supported SPDY version is 3.0. The feature needs to be enabled explicitly via QNetworkRequest::SpdyAllowedAttribute. Whether SPDY actually was used can be determined via QNetworkRequest::SpdyWasUsedAttribute from a QNetworkReply once it has been started (i.e. after the encrypted() signal has been received). Whether SPDY can be used will be determined during the SSL handshake through the TLS NPN extension (see separate commit). The following things from SPDY have not been enabled currently: * server push is not implemented, it has never been seen in the wild; in that case we just reject a stream pushed by the server, which is legit. * settings are not persisted across SPDY sessions. In practice this means that the server sends a small message upon session start telling us e.g. the number of concurrent connections. * SSL client certificates are not supported. Task-number: QTBUG-18714 [ChangeLog][QtNetwork] Added support for the SPDY protocol (version 3.0). Change-Id: I81bbe0495c24ed84e9cf8af3a9dbd63ca1e93d0d Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'tests/benchmarks/network/access/qnetworkreply')
-rw-r--r--tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp43
1 files changed, 39 insertions, 4 deletions
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 55376d5a79..3b8565a0ec 100644
--- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -52,6 +52,7 @@
#ifdef QT_BUILD_INTERNAL
#include <QtNetwork/private/qhostinfo_p.h>
+#include <QtNetwork/private/qsslsocket_openssl_p.h>
#endif
Q_DECLARE_METATYPE(QSharedPointer<char>)
@@ -552,10 +553,16 @@ void tst_qnetworkreply::echoPerformance()
void tst_qnetworkreply::preConnectEncrypted()
{
+ QFETCH(int, sleepTime);
+ QFETCH(QSslConfiguration, sslConfiguration);
+ bool spdyEnabled = !sslConfiguration.isNull();
+
QString hostName = QLatin1String("www.google.com");
QNetworkAccessManager manager;
QNetworkRequest request(QUrl("https://" + hostName));
+ if (spdyEnabled)
+ request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true);
// make sure we have a full request including
// DNS lookup, TCP and SSL handshakes
@@ -581,8 +588,12 @@ void tst_qnetworkreply::preConnectEncrypted()
manager.clearAccessCache();
// now try to make the connection beforehand
- QFETCH(int, sleepTime);
- manager.connectToHostEncrypted(hostName);
+ if (spdyEnabled) {
+ request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true);
+ manager.connectToHostEncrypted(hostName, 443, sslConfiguration);
+ } else {
+ manager.connectToHostEncrypted(hostName);
+ }
QTestEventLoop::instance().enterLoopMSecs(sleepTime);
// now make another request and hopefully use the existing connection
@@ -590,18 +601,42 @@ void tst_qnetworkreply::preConnectEncrypted()
QNetworkReply *preConnectReply = normalResult.first;
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(preConnectReply->error() == QNetworkReply::NoError);
+ bool spdyWasUsed = preConnectReply->attribute(QNetworkRequest::SpdyWasUsedAttribute).toBool();
+ QCOMPARE(spdyEnabled, spdyWasUsed);
qint64 preConnectElapsed = preConnectResult.second;
qDebug() << request.url().toString() << "full request:" << normalElapsed
<< "ms, pre-connect request:" << preConnectElapsed << "ms, difference:"
<< (normalElapsed - preConnectElapsed) << "ms";
}
+
#endif // !QT_NO_SSL
void tst_qnetworkreply::preConnectEncrypted_data()
{
+#ifndef QT_NO_OPENSSL
QTest::addColumn<int>("sleepTime");
- QTest::newRow("2secs") << 2000; // to start a new request after preconnecting is done
- QTest::newRow("100ms") << 100; // to start a new request while preconnecting is in-flight
+ QTest::addColumn<QSslConfiguration>("sslConfiguration");
+
+ // start a new normal request after preconnecting is done
+ QTest::newRow("HTTPS-2secs") << 2000 << QSslConfiguration();
+
+ // start a new normal request while preconnecting is in-flight
+ QTest::newRow("HTTPS-100ms") << 100 << QSslConfiguration();
+
+ QSslConfiguration spdySslConf = QSslConfiguration::defaultConfiguration();
+ QList<QByteArray> nextProtocols = QList<QByteArray>()
+ << QSslConfiguration::NextProtocolSpdy3_0
+ << QSslConfiguration::NextProtocolHttp1_1;
+ spdySslConf.setAllowedNextProtocols(nextProtocols);
+
+#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
+ // start a new SPDY request while preconnecting is done
+ QTest::newRow("SPDY-2secs") << 2000 << spdySslConf;
+
+ // start a new SPDY request while preconnecting is in-flight
+ QTest::newRow("SPDY-100ms") << 100 << spdySslConf;
+#endif // defined (QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) ...
+#endif // QT_NO_OPENSSL
}
void tst_qnetworkreply::downloadPerformance()