diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-02-09 13:09:24 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-02-09 13:37:02 (GMT) |
commit | 79a7572bf2aa42ca246cb7efd53e3dac2cd426bc (patch) | |
tree | 27d68f656f6d74d746f5914f5342b8f5f293fb6c /src/network/access | |
parent | 416155f9078d9d055f72b383f7cce113cdc42645 (diff) | |
download | Qt-79a7572bf2aa42ca246cb7efd53e3dac2cd426bc.zip Qt-79a7572bf2aa42ca246cb7efd53e3dac2cd426bc.tar.gz Qt-79a7572bf2aa42ca246cb7efd53e3dac2cd426bc.tar.bz2 |
QNAM HTTP: Reserve bytes for HTTP parsing
Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network/access')
-rw-r--r-- | src/network/access/qhttpnetworkreply.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index c56a3a3..6615410 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -423,6 +423,11 @@ int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteA qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket) { + if (fragment.isEmpty()) { + // reserve bytes for the status line. This is better than always append() which reallocs the byte array + fragment.reserve(32); + } + qint64 bytes = 0; char c; qint64 haveRead = 0; @@ -502,6 +507,13 @@ bool QHttpNetworkReplyPrivate::parseStatus(const QByteArray &status) qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket) { + if (fragment.isEmpty()) { + // according to http://dev.opera.com/articles/view/mama-http-headers/ the average size of the header + // block is 381 bytes. + // reserve bytes. This is better than always append() which reallocs the byte array. + fragment.reserve(512); + } + qint64 bytes = 0; char c = 0; bool allHeaders = false; |