[Solved] createRequest does not finish



  • I can not do QNetworkAccessManager::createRequest finalize request. I tried finished(QNetworkRequest), but nothing happens, see how was the WebInspector:

    !http://i.stack.imgur.com/7IA6s.png(error)!

    The request is pending and never ends.

    What am I doing wrong?

    My code:

    @QNetworkReply * myNAM::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData){
    QNetworkAccessManager *n = new QNetworkAccessManager();

     QNetworkRequest req(request.url());
    
     const QList<QByteArray>a = request.rawHeaderList();
     int j = a.length();
     int i=0;
    
     for(;i<j;++i){
      req.setRawHeader(a[i],request.rawHeader(a[i]));
     }
    
     QList<QNetworkCookie> cookies = CookiesGlobals->cookiesForUrl(request.url());
     n->cookieJar()->setCookiesFromUrl(cookies,request.url());
    
     QNetworkReply *p;
     if(op==PostOperation) {
      const QByteArray data = outgoingData->readAll();
      p = n->post(req, data);
     } eles {
      p = n->get(req);
     }
    
     QEventLoop loop;
     connect(p, SIGNAL(finished()), &loop, SLOT(quit()));
     loop.exec&#40;&#41;;
    
     QVariant statusCode = p->attribute(QNetworkRequest::HttpStatusCodeAttribute&#41;;
     if (statusCode.isValid()){
      int status = statusCode.toInt();
      qDebug() << "FB: " status;
     } else {
      qDebug() << "FB: statusCode isInvalid";
     }
     finished(p);
     return p;
    }@


  • Solution, removed QEventLoop, update code:
    http://stackoverflow.com/a/17915208/1518921


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.