diff options
author | Peter Hartmann <peter.hartmann@nokia.com> | 2011-07-05 14:21:50 (GMT) |
---|---|---|
committer | Peter Hartmann <peter.hartmann@nokia.com> | 2011-07-05 15:57:30 (GMT) |
commit | b487fb1cc1a3be4a197ec458fc3b575d7b57d6a5 (patch) | |
tree | edff12a5c6b32ed57cb14d8675ca140f37ef8e25 | |
parent | be63b3e85c50e56b18d0f0bf93ad3b1c74049117 (diff) | |
download | Qt-b487fb1cc1a3be4a197ec458fc3b575d7b57d6a5.zip Qt-b487fb1cc1a3be4a197ec458fc3b575d7b57d6a5.tar.gz Qt-b487fb1cc1a3be4a197ec458fc3b575d7b57d6a5.tar.bz2 |
HTTP internals: do not discard data if not receiving gzip end marker
some servers send gzip data without the gzip end markers. In that case,
we should deliver all content and tear down the gzip data structures.
Reviewed-by: Markus Goetz
Patch-by: Tor Arne Vestbø and Peter Hartmann
Task-number: QTBUG-16022
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 7 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply.cpp | 10 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply_p.h | 1 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 63f923f..7c2e2a1 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 516841a..01360d5 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -434,12 +434,18 @@ int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteA } while (inflateStrm.avail_out == 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 05feaa9..365308f 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(); |