summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2009-07-09 10:40:22 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2009-07-09 10:41:13 (GMT)
commit6574240d8ea657d02c3d5bf5567da7d28f42d69b (patch)
tree99a4d2715f1a0e82dae9833a28f3cb72a4f68a3d /src
parent14ef40f9b96c5afea9d08701a2a1856388349f9e (diff)
downloadQt-6574240d8ea657d02c3d5bf5567da7d28f42d69b.zip
Qt-6574240d8ea657d02c3d5bf5567da7d28f42d69b.tar.gz
Qt-6574240d8ea657d02c3d5bf5567da7d28f42d69b.tar.bz2
QHttpNetworkReply: Cache isChunked
Cache return value of expensive function. Reviewed-by: Peter Hartmann
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qhttpnetworkreply.cpp6
-rw-r--r--src/network/access/qhttpnetworkreply_p.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 483589b..7a616aa 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -201,6 +201,7 @@ bool QHttpNetworkReply::isFinished() const
QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
: QHttpNetworkHeaderPrivate(newUrl), state(NothingDoneState), statusCode(100),
majorVersion(0), minorVersion(0), bodyLength(0), contentRead(0), totalProgress(0),
+ chunkedTransferEncoding(0),
currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false),
autoDecompress(false), responseData(0), requestIsPrepared(false)
{
@@ -506,6 +507,9 @@ qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket)
state = ReadingDataState;
fragment.clear(); // next fragment
bodyLength = contentLength(); // cache the length
+
+ // cache isChunked() since it is called often
+ chunkedTransferEncoding = headerField("transfer-encoding").toLower().contains("chunked");
}
return bytes;
}
@@ -546,7 +550,7 @@ void QHttpNetworkReplyPrivate::parseHeader(const QByteArray &header)
bool QHttpNetworkReplyPrivate::isChunked()
{
- return headerField("transfer-encoding").toLower().contains("chunked");
+ return chunkedTransferEncoding;
}
bool QHttpNetworkReplyPrivate::connectionCloseEnabled()
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index b86cfaa..5eb70ce 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -198,6 +198,7 @@ public:
qint64 contentRead;
qint64 totalProgress;
QByteArray fragment; // used for header, status, chunk header etc, not for reply data
+ bool chunkedTransferEncoding;
qint64 currentChunkSize;
qint64 currentChunkRead;
QPointer<QHttpNetworkConnection> connection;