blob: d1406be9aab2c0440593cf5e1b5b6bbb43976ee3 (
plain) (
blame)
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
|
#ifndef NAM_H_
#define NAM_H_
#include <QNetworkAccessManager>
#include <QRegularExpression>
#include <QNetworkReply>
/**
* Block certain requests based on URL
*/
class SlxNetworkAccessManager : public QNetworkAccessManager
{
Q_OBJECT
public:
SlxNetworkAccessManager(QRegularExpression blackList, QRegularExpression whiteList, QObject *parent = nullptr)
: QNetworkAccessManager(parent), _black(blackList), _white(whiteList) { }
protected:
QNetworkReply* createRequest(QNetworkAccessManager::Operation op,
const QNetworkRequest &originalReq, QIODevice *outgoingData = nullptr) override;
private:
QRegularExpression _black, _white;
};
class SlxDisabledNetworkReply : public QNetworkReply
{
Q_OBJECT
public:
SlxDisabledNetworkReply(QObject *parent, const QNetworkRequest &req,
QNetworkAccessManager::Operation op);
~SlxDisabledNetworkReply() {}
void abort() override { }
protected:
qint64 readData(char *, qint64) override { return -1; }
};
#endif
|