mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-21 14:23:54 -07:00
fix: Disable HTTP compression when downloading pictures (#5793)
This causes Qt to leak file descriptors and causes the "Too many open file descriptors" error that we sporadically see, see https://bugreports.qt.io/browse/QTBUG-135641
This commit is contained in:
parent
9463390e80
commit
b214933da9
1 changed files with 17 additions and 0 deletions
|
|
@ -244,6 +244,23 @@ QNetworkReply *PictureLoaderWorker::makeRequest(const QUrl &url)
|
||||||
|
|
||||||
QNetworkRequest req(url);
|
QNetworkRequest req(url);
|
||||||
|
|
||||||
|
// QNetworkDiskCache leaks file descriptors when downloading compressed
|
||||||
|
// files, see https://bugreports.qt.io/browse/QTBUG-135641
|
||||||
|
//
|
||||||
|
// We can set the Accept-Encoding header manually to disable Qt's automatic
|
||||||
|
// response decompression, but then we would have to deal with decompression
|
||||||
|
// ourselves.
|
||||||
|
//
|
||||||
|
// Since we are dowloading images that are usually stored in a
|
||||||
|
// compressed format (e.g. jpeg or webp), it's not clear compression at the
|
||||||
|
// HTTP level helps; in fact, images are typically returned without
|
||||||
|
// compression. Redirects, on the other hand, are compressed and cause file
|
||||||
|
// descriptor leaks -- but since redirects have no payload, we don't really
|
||||||
|
// care either.
|
||||||
|
//
|
||||||
|
// In the end, just do the simple thing and disable HTTP compression.
|
||||||
|
req.setRawHeader("accept-encoding", "identity");
|
||||||
|
|
||||||
if (!picDownload) {
|
if (!picDownload) {
|
||||||
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
|
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue