diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-08-20 14:58:58 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-08-20 14:58:58 (GMT) |
commit | 851a858fcd28c35dff2ffbeffdb40f7ee69f45b4 (patch) | |
tree | f76f604982f127af7ef66d904038cdfa705ff3af /demos/browser/networkaccessmanager.cpp | |
parent | efea248b4b725ca429793874eb168ad4b43c7994 (diff) | |
parent | c0b24b7ce12387aff6e74b05b4060c61a58d87e0 (diff) | |
download | Qt-851a858fcd28c35dff2ffbeffdb40f7ee69f45b4.zip Qt-851a858fcd28c35dff2ffbeffdb40f7ee69f45b4.tar.gz Qt-851a858fcd28c35dff2ffbeffdb40f7ee69f45b4.tar.bz2 |
Merge commit 'qt/master'
Conflicts:
examples/painting/svgviewer/files/bubbles.svg
src/corelib/kernel/qobject.cpp
src/network/kernel/qhostinfo.cpp
tests/auto/qhostinfo/tst_qhostinfo.cpp
Diffstat (limited to 'demos/browser/networkaccessmanager.cpp')
-rw-r--r-- | demos/browser/networkaccessmanager.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/demos/browser/networkaccessmanager.cpp b/demos/browser/networkaccessmanager.cpp index 3781652..3ce9c08 100644 --- a/demos/browser/networkaccessmanager.cpp +++ b/demos/browser/networkaccessmanager.cpp @@ -57,16 +57,21 @@ #include <QtNetwork/QAuthenticator> #include <QtNetwork/QNetworkDiskCache> #include <QtNetwork/QNetworkProxy> +#include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkReply> #include <QtNetwork/QSslError> NetworkAccessManager::NetworkAccessManager(QObject *parent) - : QNetworkAccessManager(parent) + : QNetworkAccessManager(parent), + requestFinishedCount(0), requestFinishedFromCacheCount(0), requestFinishedPipelinedCount(0), + requestFinishedSecureCount(0) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); + connect(this, SIGNAL(finished(QNetworkReply *)), + SLOT(requestFinished(QNetworkReply *))); #ifndef QT_NO_OPENSSL connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&))); @@ -79,6 +84,35 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) setCache(diskCache); } +QNetworkReply* NetworkAccessManager::createRequest(Operation op, const QNetworkRequest & req, QIODevice * outgoingData) +{ + QNetworkRequest request = req; // copy so we can modify + // this is a temporary hack until we properly use the pipelining flags from QtWebkit + // pipeline everything! :) + request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + return QNetworkAccessManager::createRequest(op, request, outgoingData); +} + +void NetworkAccessManager::requestFinished(QNetworkReply *reply) +{ + requestFinishedCount++; + + if (reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool() == true) + requestFinishedFromCacheCount++; + + if (reply->attribute(QNetworkRequest::HttpPipeliningWasUsedAttribute).toBool() == true) + requestFinishedPipelinedCount++; + + if (reply->attribute(QNetworkRequest::ConnectionEncryptedAttribute).toBool() == true) + requestFinishedSecureCount++; + + double pctCached = (double(requestFinishedFromCacheCount) * 100.0/ double(requestFinishedCount)); + double pctPipelined = (double(requestFinishedPipelinedCount) * 100.0/ double(requestFinishedCount)); + double pctSecure = (double(requestFinishedSecureCount) * 100.0/ double(requestFinishedCount)); + qDebug("%lli requests [%3.2f%% from cache] [%3.2f%% pipelined] [%3.2f%% SSL/TLS]", requestFinishedCount, pctCached, pctPipelined, pctSecure); + +} + void NetworkAccessManager::loadSettings() { QSettings settings; |