blob: e6bd5233998b4b640d42db87b77ef3967b2458dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/*
* This file is part of smolbote. It's copyrighted by the contributors recorded
* in the version control history of the file, available from its original
* location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
*
* SPDX-License-Identifier: GPL-3.0
*/
#include "urlinterceptor.h"
#include "urlfilter/formats/adblockrule.h"
#include <QDir>
#include <QJsonArray>
#include <QJsonDocument>
#include <QTextStream>
#include <boost/algorithm/string.hpp>
#include <configuration/configuration.h>
#include "filter.h"
#include <web/webprofile.h>
// test DNT on https://browserleaks.com/donottrack
UrlRequestInterceptor::UrlRequestInterceptor(Filter* filter, WebProfile* profile, QObject* parent)
: QWebEngineUrlRequestInterceptor(parent)
{
Q_CHECK_PTR(filter);
m_filter = filter;
Q_CHECK_PTR(profile);
m_profile = profile;
}
void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
m_filter->filterRequest(info);
// set headers
for(auto i = m_filter->headers().constBegin(); i != m_filter->headers().constEnd(); ++i) {
info.setHttpHeader(i.key(), i.value());
}
for(auto i = m_profile->headers().constBegin(); i != m_profile->headers().constEnd(); ++i) {
info.setHttpHeader(i.key(), i.value());
}
}
|