diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-07-06 08:52:50 +1000 |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-07-06 08:52:50 +1000 |
commit | 156893a247f1c24094129b6f5151c8b821d8b1b5 (patch) | |
tree | 934ad4c92daacb04a125e04ce991471ca3eaf9f7 | |
parent | f46d3aa61e8f9c27c5ff60bbd23d85f0c31df84c (diff) | |
parent | cc504be6500911d9109f513a60c8116cacb39fe4 (diff) | |
download | qt4-tools-156893a247f1c24094129b6f5151c8b821d8b1b5.tar.gz |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
HTTP internals: continue gzip decompression if buffer fills exactly
HTTP internals: do not discard data if not receiving gzip end marker
Add a null check for the backend in QNetworkReplyImpl.
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 7 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply.cpp | 12 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply_p.h | 1 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 2 |
4 files changed, 16 insertions, 6 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 63f923f36d..7c2e2a1585 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -599,8 +599,11 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete) int ret = Z_OK; if (content.size()) ret = reply->d_func()->gunzipBodyPartially(content, inflated); - int retCheck = (dataComplete) ? Z_STREAM_END : Z_OK; - if (ret >= retCheck) { + if (ret >= Z_OK) { + if (dataComplete && ret == Z_OK && !reply->d_func()->streamEnd) { + reply->d_func()->gunzipBodyPartiallyEnd(); + reply->d_func()->streamEnd = true; + } if (inflated.size()) { reply->d_func()->totalProgress += inflated.size(); reply->d_func()->appendUncompressedReplyData(inflated); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 516841a2ea..0f2fcbaa92 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -431,15 +431,21 @@ int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteA } have = sizeof(out) - inflateStrm.avail_out; inflated.append(QByteArray((const char *)out, have)); - } while (inflateStrm.avail_out == 0); + } while (inflateStrm.avail_out == 0 && inflateStrm.avail_in > 0); // clean up and return if (ret <= Z_ERRNO || ret == Z_STREAM_END) { - inflateEnd(&inflateStrm); - initInflate = false; + gunzipBodyPartiallyEnd(); } streamEnd = (ret == Z_STREAM_END); return ret; } + +void QHttpNetworkReplyPrivate::gunzipBodyPartiallyEnd() +{ + inflateEnd(&inflateStrm); + initInflate = false; +} + #endif qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket) diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 05feaa9509..365308f668 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -200,6 +200,7 @@ public: #ifndef QT_NO_COMPRESS bool gzipCheckHeader(QByteArray &content, int &pos); int gunzipBodyPartially(QByteArray &compressed, QByteArray &inflated); + void gunzipBodyPartiallyEnd(); #endif void removeAutoDecompressHeader(); diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 574b6e996e..8a0a944a54 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -924,7 +924,7 @@ bool QNetworkReplyImplPrivate::migrateBackend() return true; // Backend does not support resuming download. - if (!backend->canResume()) + if (backend && !backend->canResume()) return false; state = QNetworkReplyImplPrivate::Reconnecting; |