header.setValue("Accept-Encoding", "gzip,deflate");
nun frage gibt es eine moeglichkeit den empfangene QByteArray zu decoprimieren ohne file so im buffer?
zur zeit oeffne ich ein file dekomprimiere lese und loesche ich das file... aber geht es auch anders....
Code: Alles auswählen
void GetHttp::DecompressStream()
{
/* QByteArray byteArray; incomming data */
QChar letter('A' + (qrand() % 26));
const QString tmpfiler = QString("%1http_%2.gz").arg(WORK_CACHEDIR).arg(letter);
QFile f( tmpfiler );
if ( f.open( QIODevice::WriteOnly ) ) {
f.write(byteArray);
f.close();
} else {
std::cout << "### Unable to work on cache dir!. " << std::endl;
return;
}
gzFile file;
file = gzopen (tmpfiler.toUtf8().data(),"rb");
if(!file) {
std::cout << "### Unable to work on cache dir!. " << std::endl;
return;
}
QByteArray input;
char buffer[1024];
QByteArray inputData;
while(int readBytes = gzread (file, buffer, 1024))
{
input.append(QByteArray(buffer, readBytes));
}
gzclose(file);
f.remove();
byteArray.clear();
byteArray.append(input);
}
if (Compressed) {
if (zipmode == GZIP_MODE || zipmode == DEFLATE_MODE ) {
DecompressStream();
} else if (zipmode == QT_MODE) {
QByteArray input = qUncompress(byteArray);
byteArray.clear();
byteArray.append(input);
}
} else {
.....