mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 07:27:22 -06:00
Revise Utils::Gzip::compress code
Change signature Add ZLIB_CONST define to make z_stream.next_in const Cast to zlib defined type Bytef* Set memLevel to 9 in deflateInit2() for maximum performance Revise compression loop On returning false, free memory correctly by calling deflateEnd() Reserve space by the estimation of deflateBound()
This commit is contained in:
@@ -93,14 +93,15 @@ void Http::compressContent(Response &response)
|
||||
return;
|
||||
|
||||
// try compressing
|
||||
QByteArray buf;
|
||||
if (!Utils::Gzip::compress(response.content, buf))
|
||||
bool ok = false;
|
||||
const QByteArray compressedData = Utils::Gzip::compress(response.content, 6, &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
// "Content-Encoding: gzip\r\n" is 24 bytes long
|
||||
if ((buf.size() + 24) >= contentSize)
|
||||
if ((compressedData.size() + 24) >= contentSize)
|
||||
return;
|
||||
|
||||
response.content = buf;
|
||||
response.content = compressedData;
|
||||
response.headers[HEADER_CONTENT_ENCODING] = QLatin1String("gzip");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user