mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Bring back support for sending DNT header to servers
This commit is contained in:
parent
39c920f3ce
commit
3ec6da6103
@ -237,4 +237,6 @@ void NetworkManager::loadSettings()
|
||||
settings.endGroup();
|
||||
|
||||
mApp->webProfile()->setHttpAcceptLanguage(AcceptLanguage::generateHeader(langs));
|
||||
|
||||
m_urlInterceptor->loadSettings();
|
||||
}
|
||||
|
@ -18,20 +18,29 @@
|
||||
|
||||
#include "networkurlinterceptor.h"
|
||||
#include "urlinterceptor.h"
|
||||
#include "settings.h"
|
||||
|
||||
NetworkUrlInterceptor::NetworkUrlInterceptor(QObject *parent)
|
||||
: QWebEngineUrlRequestInterceptor(parent)
|
||||
, m_sendDNT(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool NetworkUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
|
||||
{
|
||||
foreach (UrlInterceptor *interceptor, m_interceptors) {
|
||||
if (interceptor->interceptRequest(info))
|
||||
return true;
|
||||
bool result = false;
|
||||
|
||||
if (m_sendDNT) {
|
||||
result = true;
|
||||
info.setExtraHeader(QByteArrayLiteral("DNT"), QByteArrayLiteral("1"));
|
||||
}
|
||||
|
||||
return false;
|
||||
foreach (UrlInterceptor *interceptor, m_interceptors) {
|
||||
if (interceptor->interceptRequest(info))
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void NetworkUrlInterceptor::installUrlInterceptor(UrlInterceptor *interceptor)
|
||||
@ -44,3 +53,11 @@ void NetworkUrlInterceptor::removeUrlInterceptor(UrlInterceptor *interceptor)
|
||||
{
|
||||
m_interceptors.removeOne(interceptor);
|
||||
}
|
||||
|
||||
void NetworkUrlInterceptor::loadSettings()
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup("Web-Browser-Settings");
|
||||
m_sendDNT = settings.value("DoNotTrack", false).toBool();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
@ -35,8 +35,11 @@ public:
|
||||
void installUrlInterceptor(UrlInterceptor *interceptor);
|
||||
void removeUrlInterceptor(UrlInterceptor *interceptor);
|
||||
|
||||
void loadSettings();
|
||||
|
||||
private:
|
||||
QList<UrlInterceptor*> m_interceptors;
|
||||
bool m_sendDNT;
|
||||
};
|
||||
|
||||
#endif // NETWORKURLINTERCEPTOR_H
|
||||
|
Loading…
Reference in New Issue
Block a user