diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 6 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply.cpp | 13 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply_p.h | 3 |
4 files changed, 15 insertions, 9 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index b51c0bb..b111bec 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -603,7 +603,7 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) for (int i = 0; i < channelCount; ++i) { if (channels[i].reply == reply) { channels[i].reply = 0; - if (reply->d_func()->connectionCloseEnabled()) + if (reply->d_func()->isConnectionCloseEnabled()) channels[i].close(); QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); return; diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 05c6ebe..d880f60 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -524,7 +524,7 @@ void QHttpNetworkConnectionChannel::allDone() handleStatus(); // ### at this point there should be no more data on the socket // close if server requested - if (reply->d_func()->connectionCloseEnabled()) + if (reply->d_func()->isConnectionCloseEnabled()) close(); // queue the finished signal, this is required since we might send new requests from // slot connected to it. The socket will not fire readyRead signal, if we are already @@ -539,7 +539,7 @@ void QHttpNetworkConnectionChannel::allDone() // move next from pipeline to current request if (!alreadyPipelinedRequests.isEmpty()) { - if (resendCurrent || reply->d_func()->connectionCloseEnabled() || socket->state() != QAbstractSocket::ConnectedState) { + if (resendCurrent || reply->d_func()->isConnectionCloseEnabled() || socket->state() != QAbstractSocket::ConnectedState) { // move the pipelined ones back to the main queue requeueCurrentlyPipelinedRequests(); } else { @@ -584,7 +584,7 @@ void QHttpNetworkConnectionChannel::detectPipeliningSupport() // check for HTTP/1.1 && (reply->d_func()->majorVersion == 1 && reply->d_func()->minorVersion == 1) // check for not having connection close - && (!reply->d_func()->connectionCloseEnabled()) + && (!reply->d_func()->isConnectionCloseEnabled()) // check if it is still connected && (socket->state() == QAbstractSocket::ConnectedState) ) { diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index ba429fd..d3d57d4 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -196,7 +196,8 @@ bool QHttpNetworkReply::isPipeliningUsed() const QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl) : QHttpNetworkHeaderPrivate(newUrl), state(NothingDoneState), statusCode(100), majorVersion(0), minorVersion(0), bodyLength(0), contentRead(0), totalProgress(0), - chunkedTransferEncoding(0), + chunkedTransferEncoding(false), + connectionCloseEnabled(true), currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false), autoDecompress(false), responseData(), requestIsPrepared(false) ,pipeliningUsed(false) @@ -216,6 +217,7 @@ void QHttpNetworkReplyPrivate::clear() totalProgress = 0; currentChunkSize = 0; currentChunkRead = 0; + connectionCloseEnabled = true; connection = 0; #ifndef QT_NO_COMPRESS if (initInflate) @@ -510,6 +512,10 @@ qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket) // cache isChunked() since it is called often chunkedTransferEncoding = headerField("transfer-encoding").toLower().contains("chunked"); + + // cache isConnectionCloseEnabled since it is called often + connectionCloseEnabled = (headerField("connection").toLower().contains("close") || + headerField("proxy-connection").toLower().contains("close")); } return bytes; } @@ -553,10 +559,9 @@ bool QHttpNetworkReplyPrivate::isChunked() return chunkedTransferEncoding; } -bool QHttpNetworkReplyPrivate::connectionCloseEnabled() +bool QHttpNetworkReplyPrivate::isConnectionCloseEnabled() { - return (headerField("connection").toLower().contains("close") || - headerField("proxy-connection").toLower().contains("close")); + return connectionCloseEnabled; } // note this function can only be used for non-chunked, non-compressed with diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 8d4d724..cfc1523 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -185,7 +185,7 @@ public: qint64 bytesAvailable() const; bool isChunked(); - bool connectionCloseEnabled(); + bool isConnectionCloseEnabled(); bool isGzipped(); #ifndef QT_NO_COMPRESS bool gzipCheckHeader(QByteArray &content, int &pos); @@ -212,6 +212,7 @@ public: qint64 totalProgress; QByteArray fragment; // used for header, status, chunk header etc, not for reply data bool chunkedTransferEncoding; + bool connectionCloseEnabled; qint64 currentChunkSize; qint64 currentChunkRead; QPointer<QHttpNetworkConnection> connection; |