Use built-in method for setting header

PR #21961.
This commit is contained in:
Chocobo1 2024-12-08 16:33:35 +08:00 committed by GitHub
parent 3fcc298539
commit cbf7c09bf4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -320,14 +320,11 @@ void Net::DownloadManager::processRequest(DownloadHandlerImpl *downloadHandler)
const DownloadRequest downloadRequest = downloadHandler->downloadRequest();
QNetworkRequest request {downloadRequest.url()};
if (downloadRequest.userAgent().isEmpty())
request.setRawHeader("User-Agent", getBrowserUserAgent());
else
request.setRawHeader("User-Agent", downloadRequest.userAgent().toUtf8());
request.setHeader(QNetworkRequest::UserAgentHeader, (downloadRequest.userAgent().isEmpty()
? getBrowserUserAgent() : downloadRequest.userAgent().toUtf8()));
// Spoof HTTP Referer to allow adding torrent link from Torcache/KickAssTorrents
request.setRawHeader("Referer", request.url().toEncoded().data());
request.setRawHeader("Referer", request.url().toEncoded());
#ifdef QT_NO_COMPRESS
// The macro "QT_NO_COMPRESS" defined in QT will disable the zlib related features
// and reply data auto-decompression in QT will also be disabled. But we can support