};
QZipReader::FileInfo::FileInfo()
- : isDir(false), isFile(false), isSymLink(false), crc32(0), size(0)
+ : isDir(false), isFile(false), isSymLink(false), crc(0), size(0)
{
}
isFile = other.isFile;
isSymLink = other.isSymLink;
permissions = other.permissions;
- crc32 = other.crc32;
+ crc = other.crc;
size = other.size;
lastModified = other.lastModified;
return *this;
fileInfo.isFile = S_ISREG(mode);
fileInfo.isSymLink = S_ISLNK(mode);
fileInfo.permissions = modeToPermissions(mode);
- fileInfo.crc32 = readUInt(header.h.crc_32);
+ fileInfo.crc = readUInt(header.h.crc_32);
fileInfo.size = readUInt(header.h.uncompressed_size);
fileInfo.lastModified = readMSDosDate(header.h.last_mod_file);
}
*/
/*!
- \variable FileInfo::crc32
- The calculated checksum as a crc32 type.
+ \variable FileInfo::crc
+ The calculated checksum as a crc type.
*/
/*!
# include <QtNetwork/qsslconfiguration.h>
#endif
+#ifndef QT_NO_COMPRESS
+#include <zlib.h>
+#endif
+
QT_BEGIN_NAMESPACE
QHttpNetworkReply::QHttpNetworkReply(const QUrl &url, QObject *parent)
}
#ifndef QT_NO_COMPRESS
- if (d->autoDecompress && d->isCompressed())
- inflateEnd(&d->inflateStrm);
+ if (d->autoDecompress && d->isCompressed() && d->inflateStrm)
+ inflateEnd(d->inflateStrm);
#endif
}
autoDecompress(false), responseData(), requestIsPrepared(false)
,pipeliningUsed(false), downstreamLimited(false)
,userProvidedDownloadBuffer(0)
+#ifndef QT_NO_COMPRESS
+ ,inflateStrm(0)
+#endif
+
{
}
QHttpNetworkReplyPrivate::~QHttpNetworkReplyPrivate()
{
+#ifndef QT_NO_COMPRESS
+ if (inflateStrm)
+ delete inflateStrm;
+#endif
}
void QHttpNetworkReplyPrivate::clearHttpLayerInformation()
lastChunkRead = false;
connectionCloseEnabled = true;
#ifndef QT_NO_COMPRESS
- if (autoDecompress)
- inflateEnd(&inflateStrm);
+ if (autoDecompress && inflateStrm)
+ inflateEnd(inflateStrm);
#endif
fields.clear();
}
#ifndef QT_NO_COMPRESS
if (autoDecompress && isCompressed()) {
// allocate inflate state
- inflateStrm.zalloc = Z_NULL;
- inflateStrm.zfree = Z_NULL;
- inflateStrm.opaque = Z_NULL;
- inflateStrm.avail_in = 0;
- inflateStrm.next_in = Z_NULL;
+ if (!inflateStrm)
+ inflateStrm = new z_stream;
+ inflateStrm->zalloc = Z_NULL;
+ inflateStrm->zfree = Z_NULL;
+ inflateStrm->opaque = Z_NULL;
+ inflateStrm->avail_in = 0;
+ inflateStrm->next_in = Z_NULL;
// "windowBits can also be greater than 15 for optional gzip decoding.
// Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
// http://www.zlib.net/manual.html
- int ret = inflateInit2(&inflateStrm, MAX_WBITS+32);
+ int ret = inflateInit2(inflateStrm, MAX_WBITS+32);
if (ret != Z_OK)
return -1;
}
#ifndef QT_NO_COMPRESS
qint64 QHttpNetworkReplyPrivate::uncompressBodyData(QByteDataBuffer *in, QByteDataBuffer *out)
{
+ if (!inflateStrm)
+ return -1;
+
bool triedRawDeflate = false;
for (int i = 0; i < in->bufferCount(); i++) {
QByteArray &bIn = (*in)[i];
- inflateStrm.avail_in = bIn.size();
- inflateStrm.next_in = reinterpret_cast<Bytef*>(bIn.data());
+ inflateStrm->avail_in = bIn.size();
+ inflateStrm->next_in = reinterpret_cast<Bytef*>(bIn.data());
do {
QByteArray bOut;
// make a wild guess about the uncompressed size.
- bOut.reserve(inflateStrm.avail_in * 3 + 512);
- inflateStrm.avail_out = bOut.capacity();
- inflateStrm.next_out = reinterpret_cast<Bytef*>(bOut.data());
+ bOut.reserve(inflateStrm->avail_in * 3 + 512);
+ inflateStrm->avail_out = bOut.capacity();
+ inflateStrm->next_out = reinterpret_cast<Bytef*>(bOut.data());
- int ret = inflate(&inflateStrm, Z_NO_FLUSH);
+ int ret = inflate(inflateStrm, Z_NO_FLUSH);
//All negative return codes are errors, in the context of HTTP compression, Z_NEED_DICT is also an error.
// in the case where we get Z_DATA_ERROR this could be because we recieved raw deflate compressed data.
if (ret == Z_DATA_ERROR && !triedRawDeflate) {
- inflateEnd(&inflateStrm);
+ inflateEnd(inflateStrm);
triedRawDeflate = true;
- inflateStrm.zalloc = Z_NULL;
- inflateStrm.zfree = Z_NULL;
- inflateStrm.opaque = Z_NULL;
- inflateStrm.avail_in = 0;
- inflateStrm.next_in = Z_NULL;
- int ret = inflateInit2(&inflateStrm, -MAX_WBITS);
+ inflateStrm->zalloc = Z_NULL;
+ inflateStrm->zfree = Z_NULL;
+ inflateStrm->opaque = Z_NULL;
+ inflateStrm->avail_in = 0;
+ inflateStrm->next_in = Z_NULL;
+ int ret = inflateInit2(inflateStrm, -MAX_WBITS);
if (ret != Z_OK) {
return -1;
} else {
- inflateStrm.avail_in = bIn.size();
- inflateStrm.next_in = reinterpret_cast<Bytef*>(bIn.data());
+ inflateStrm->avail_in = bIn.size();
+ inflateStrm->next_in = reinterpret_cast<Bytef*>(bIn.data());
continue;
}
} else if (ret < 0 || ret == Z_NEED_DICT) {
return -1;
}
- bOut.resize(bOut.capacity() - inflateStrm.avail_out);
+ bOut.resize(bOut.capacity() - inflateStrm->avail_out);
out->append(bOut);
if (ret == Z_STREAM_END)
return out->byteAmount();
- } while (inflateStrm.avail_in > 0);
+ } while (inflateStrm->avail_in > 0);
}
return out->byteAmount();