QNetworkReply *InterceptorAccessManager::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData){ QNetworkReply *real; QByteArray* postdata; QByteArray* reqtdata; NetworkReplyProxy *proxy; if (isResourceNeeded(request)) { postdata = new QByteArray(); reqtdata = new QByteArray(); //*postdata = outgoingData->peek(outgoingData->size()); (*reqtdata)="\r\n";(*postdata)="\r\n"; QList<QByteArray> headers = request.rawHeaderList(); foreach(QByteArray req, headers) { QByteArray header = request.rawHeader(req); (*reqtdata)+=req+":"+header+"\r\n"; } real = QNetworkAccessManager::createRequest(op, request, outgoingData); proxy = new NetworkReplyProxy(this, real,reqtdata,postdata); emit pendingReplyProxy(proxy); return proxy; } else { real = QNetworkAccessManager::createRequest(op, request, outgoingData); } return real;}
C++ (Qt)*QNetworkReply MyManager::post(...request, ...postdata){ ... //Тут можно, например, выбросить сигнал с postdata. return QNetworkAccessManager::post(request, postdata);}
view = new QWebView(this); interceptor = new InterceptorAccessManager(this); view->page()->setNetworkAccessManager(interceptor); interceptor->setUrlMask(QRegExp("*.php", Qt::CaseInsensitive, QRegExp::Wildcard)); view->load(url); connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool))); connect(interceptor, SIGNAL(pendingReplyProxy(NetworkReplyProxy*)),SLOT(processCustomReply(NetworkReplyProxy*)));