mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 19:40:18 -07: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:
parent
94b496354b
commit
302c8ba850
3 changed files with 48 additions and 42 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue