add request attribute

add followredirect and prefercache
This commit is contained in:
xiaoyifang 2022-04-14 22:45:34 +08:00
parent 9779b1d723
commit b242a5b89c
2 changed files with 4 additions and 1 deletions

View file

@ -9,6 +9,7 @@ void ResourceSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
QNetworkRequest request;
request.setUrl(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
QNetworkReply *reply = this->mManager.createRequest(QNetworkAccessManager::GetOperation, request);
connect(reply, &QNetworkReply::finished, requestJob, [=]() {
if (reply->error() == QNetworkReply::ContentNotFoundError) {

View file

@ -125,7 +125,9 @@ WebSiteArticleRequest::WebSiteArticleRequest( QString const & url_,
QUrl reqUrl( url );
netReply = mgr.get( QNetworkRequest( reqUrl ) );
auto request = QNetworkRequest( reqUrl );
request.setAttribute( QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy );
netReply = mgr.get( request );
#ifndef QT_NO_OPENSSL
connect( netReply, SIGNAL( sslErrors( QList< QSslError > ) ),