diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 6 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 9 | ||||
-rw-r--r-- | src/network/access/qnetworkaccesshttpbackend.cpp | 3 | ||||
-rw-r--r-- | src/network/access/qnetworkcookiejar.cpp | 3 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 80 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl_p.h | 5 |
6 files changed, 76 insertions, 30 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index a6322a3..559124f 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -489,7 +489,11 @@ void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) int i = indexOf(socket); - if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= 2)) { + // return fast if there was no reply right now processed + if (channels[i].reply == 0) + return; + + if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength)) { return; } diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index f9a6de8..3b7bc9e 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -317,6 +317,13 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() return; } + // only run when the QHttpNetworkConnection is not currently being destructed, e.g. + // this function is called from _q_disconnected which is called because + // of ~QHttpNetworkConnectionPrivate + if (!qobject_cast<QHttpNetworkConnection*>(connection)) { + return; + } + qint64 bytes = 0; QAbstractSocket::SocketState socketState = socket->state(); @@ -384,7 +391,7 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() if (!replyPrivate->expectContent()) { replyPrivate->state = QHttpNetworkReplyPrivate::AllDoneState; allDone(); - return; + break; } } break; diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 7a48c2b..3154ed6 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -726,8 +726,7 @@ void QNetworkAccessHttpBackend::readFromHttp() QByteDataBuffer list; while (httpReply->bytesAvailable() != 0 && nextDownstreamBlockSize() != 0 && nextDownstreamBlockSize() > list.byteAmount()) { - QByteArray data = httpReply->readAny(); - list.append(data); + list.append(httpReply->readAny()); } if (!list.isEmpty()) diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index 8727095..0b3a918 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -269,6 +269,7 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const Q_D(const QNetworkCookieJar); QDateTime now = QDateTime::currentDateTime(); QList<QNetworkCookie> result; + bool isEncrypted = url.scheme().toLower() == QLatin1String("https"); // scan our cookies for something that matches QList<QNetworkCookie>::ConstIterator it = d->allCookies.constBegin(), @@ -280,6 +281,8 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const continue; if (!(*it).isSessionCookie() && (*it).expirationDate() < now) continue; + if ((*it).isSecure() && !isEncrypted) + continue; // insert this cookie into result, sorted by path QList<QNetworkCookie>::Iterator insertIt = result.begin(); diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index c3dc168..128d18f 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -478,6 +478,37 @@ qint64 QNetworkReplyImplPrivate::nextDownstreamBlockSize() const return qMax<qint64>(0, readBufferMaxSize - readBuffer.byteAmount()); } +void QNetworkReplyImplPrivate::initCacheSaveDevice() +{ + Q_Q(QNetworkReplyImpl); + + // save the meta data + QNetworkCacheMetaData metaData; + metaData.setUrl(url); + metaData = backend->fetchCacheMetaData(metaData); + + // save the redirect request also in the cache + QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirectionTarget.isValid()) { + QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes(); + attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget); + metaData.setAttributes(attributes); + } + + cacheSaveDevice = networkCache()->prepare(metaData); + + if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) { + if (cacheSaveDevice && !cacheSaveDevice->isOpen()) + qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- " + "class %s probably needs to be fixed", + networkCache()->metaObject()->className()); + + networkCache()->remove(url); + cacheSaveDevice = 0; + cacheEnabled = false; + } +} + // we received downstream data and send this to the cache // and to our readBuffer (which in turn gets read by the user of QNetworkReply) void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data) @@ -487,36 +518,12 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data) return; if (cacheEnabled && !cacheSaveDevice) { - // save the meta data - QNetworkCacheMetaData metaData; - metaData.setUrl(url); - metaData = backend->fetchCacheMetaData(metaData); - - // save the redirect request also in the cache - QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirectionTarget.isValid()) { - QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes(); - attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget); - metaData.setAttributes(attributes); - } - - cacheSaveDevice = networkCache()->prepare(metaData); - - if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) { - if (cacheSaveDevice && !cacheSaveDevice->isOpen()) - qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- " - "class %s probably needs to be fixed", - networkCache()->metaObject()->className()); - - networkCache()->remove(url); - cacheSaveDevice = 0; - cacheEnabled = false; - } + initCacheSaveDevice(); } qint64 bytesWritten = 0; for (int i = 0; i < data.bufferCount(); i++) { - QByteArray item = data[i]; + QByteArray const &item = data[i]; if (cacheSaveDevice) cacheSaveDevice->write(item.constData(), item.size()); @@ -529,6 +536,13 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data) bytesDownloaded += bytesWritten; lastBytesDownloaded = bytesDownloaded; + appendDownstreamDataSignalEmissions(); +} + +void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions() +{ + Q_Q(QNetworkReplyImpl); + QPointer<QNetworkReplyImpl> qq = q; QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); @@ -572,6 +586,15 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data) _q_copyReadyRead(); } +void QNetworkReplyImplPrivate::appendDownstreamData(const QByteArray &data) +{ + // TODO implement + + // TODO call + + qFatal("QNetworkReplyImplPrivate::appendDownstreamData not implemented"); +} + void QNetworkReplyImplPrivate::finished() { Q_Q(QNetworkReplyImpl); @@ -689,8 +712,13 @@ QNetworkReplyImpl::QNetworkReplyImpl(QObject *parent) QNetworkReplyImpl::~QNetworkReplyImpl() { Q_D(QNetworkReplyImpl); + + // This code removes the data from the cache if it was prematurely aborted. + // See QNetworkReplyImplPrivate::completeCacheSave(), we disable caching there after the cache + // save had been properly finished. So if it is still enabled it means we got deleted/aborted. if (d->isCachingEnabled()) d->networkCache()->remove(url()); + if (d->outgoingDataBuffer) delete d->outgoingDataBuffer; } diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index bc7e408..38084bd 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -156,8 +156,13 @@ public: void consume(qint64 count); void emitUploadProgress(qint64 bytesSent, qint64 bytesTotal); qint64 nextDownstreamBlockSize() const; + + void initCacheSaveDevice(); + void appendDownstreamDataSignalEmissions(); void appendDownstreamData(QByteDataBuffer &data); void appendDownstreamData(QIODevice *data); + void appendDownstreamData(const QByteArray &data); + void finished(); void error(QNetworkReply::NetworkError code, const QString &errorString); void metaDataChanged(); |