diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2011-07-06 16:08:59 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-12 15:34:12 +0200 |
commit | 2b5dcfcee118265ef7930cc7c5c16bff22d580fd (patch) | |
tree | a6950c1cdb3851f405ebee9da0429314b3f5866b /src/network/access/qhttpnetworkreply_p.h | |
parent | 363c710bc438f9c0c4c0e1c3eeb9cc2d9d2af5db (diff) |
QNAM HTTP: Re-write compression code
This eliminates some code (header parsing) that can be done by
zlib already.
Add support for 'deflate' encoding.
Also do less memory copying while uncompressing.
Change-Id: I94de21e3c58b904dd91d004c375ed8cbea56cb0b
Task-Number: QTBUG-13191
Reviewed-on: http://codereview.qt.nokia.com/1314
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network/access/qhttpnetworkreply_p.h')
-rw-r--r-- | src/network/access/qhttpnetworkreply_p.h | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 583a256ada..14219d484b 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -56,15 +56,7 @@ #ifndef QT_NO_HTTP #ifndef QT_NO_COMPRESS -# include <zlib.h> -static const unsigned char gz_magic[2] = {0x1f, 0x8b}; // gzip magic header -// gzip flag byte -#define HEAD_CRC 0x02 // bit 1 set: header CRC present -#define EXTRA_FIELD 0x04 // bit 2 set: extra field present -#define ORIG_NAME 0x08 // bit 3 set: original file name present -#define COMMENT 0x10 // bit 4 set: file comment present -#define RESERVED 0xE0 // bits 5..7: reserved -#define CHUNK 16384 +#include <zlib.h> #endif #include <QtNetwork/qtcpsocket.h> @@ -192,10 +184,6 @@ public: qint64 readReplyBodyChunked(QAbstractSocket *in, QByteDataBuffer *out); qint64 getChunkSize(QAbstractSocket *in, qint64 *chunkSize); - void appendUncompressedReplyData(QByteArray &qba); - void appendUncompressedReplyData(QByteDataBuffer &data); - void appendCompressedReplyData(QByteDataBuffer &data); - bool shouldEmitSignals(); bool expectContent(); void eraseData(); @@ -203,11 +191,8 @@ public: qint64 bytesAvailable() const; bool isChunked(); bool isConnectionCloseEnabled(); - bool isGzipped(); -#ifndef QT_NO_COMPRESS - bool gzipCheckHeader(QByteArray &content, int &pos); - int gunzipBodyPartially(QByteArray &compressed, QByteArray &inflated); -#endif + + bool isCompressed(); void removeAutoDecompressHeader(); enum ReplyState { @@ -236,11 +221,12 @@ public: qint64 currentChunkRead; QPointer<QHttpNetworkConnection> connection; QPointer<QHttpNetworkConnectionChannel> connectionChannel; - bool initInflate; - bool streamEnd; + #ifndef QT_NO_COMPRESS z_stream inflateStrm; + qint64 uncompressBodyData(QByteDataBuffer *in, QByteDataBuffer *out); #endif + bool autoDecompress; QByteDataBuffer responseData; // uncompressed body |