diff options
Diffstat (limited to 'src/network/access/qhttpnetworkreply.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkreply.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index ba429fd..ea2018d 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,13 @@ 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 + QByteArray connectionHeaderField = headerField("connection"); + // check for explicit indication of close or the implicit connection close of HTTP/1.0 + connectionCloseEnabled = (connectionHeaderField.toLower().contains("close") || + headerField("proxy-connection").toLower().contains("close")) || + (majorVersion == 1 && minorVersion == 0 && connectionHeaderField.isEmpty()); } return bytes; } @@ -553,10 +562,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 |