forked from humantech/webkit-scheme-qt5.1
/
qcustomnetworkaccessmanager.cpp
35 lines (30 loc) · 1.12 KB
/
qcustomnetworkaccessmanager.cpp
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
#include <QNetworkRequest>
#include <QDebug>
#include "qcustomnetworkreply.h"
#include "qcustomnetworkaccessmanager.h"
QCustomNetworkAccessManager::QCustomNetworkAccessManager(QNetworkAccessManager *manager, QObject *parent)
: QNetworkAccessManager( parent )
{
setCache(manager->cache());
setCookieJar(manager->cookieJar());
setProxyFactory(manager->proxyFactory());
}
QNetworkReply *QCustomNetworkAccessManager::createRequest( Operation operation,
const QNetworkRequest &request,
QIODevice *device )
{
if (request.url().scheme() != "foo")
{
return QNetworkAccessManager::createRequest( operation, request, device );
}
QCustomNetworkReply *reply = new QCustomNetworkReply(request.url());
connect(reply, SIGNAL(finished()), this, SLOT(customReplyFinished()));
return reply;
}
void QCustomNetworkAccessManager::customReplyFinished()
{
QCustomNetworkReply *reply = qobject_cast<QCustomNetworkReply *>(sender());
if (reply) {
emit finished(reply);
}
}