diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-08-27 14:34:30 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-08-27 14:36:06 (GMT) |
commit | 2c6cfddf3e1f3674f0b70880c12f6812650cd08d (patch) | |
tree | 024d4e7f98bcd6763c708deda5bceb3c6fef5945 /src/network/access/qhttpnetworkreply.cpp | |
parent | dd9499f786432687aada7c41d2073869d56f0b59 (diff) | |
download | Qt-2c6cfddf3e1f3674f0b70880c12f6812650cd08d.zip Qt-2c6cfddf3e1f3674f0b70880c12f6812650cd08d.tar.gz Qt-2c6cfddf3e1f3674f0b70880c12f6812650cd08d.tar.bz2 |
QNAM HTTP Code: Optimize connectionCloseEnabled
Was called pretty often, therefore we now calculate this once and
save it in a bool.
Reviewed-by: TrustMe
Diffstat (limited to 'src/network/access/qhttpnetworkreply.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkreply.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
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 |