Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Http post, sent 3 times

    General and Desktop
    2
    4
    1031
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      antonio last edited by

      Hi,

      I'm trying to make a post with json data, but it seems like for every post I make, it is sent 3 times. I have tested my server with Advanced REST Client (chrome) and it works fine.

      @ manager = new QNetworkAccessManager (this);
      connect (manager, SIGNAL(finished(QNetworkReply *)),
      this, SLOT(replyFinish (QNetworkReply *)));

      QNetworkRequest req.setUrl(QUrl("http://192.168.2.226:8181"));

      QByteArray postData;
      postData.append("{"cmd":"clientInfoReq","ver":"0.1","data""
      ":{"reference":"id","value":"2"}}");
      postData += "\r\n";

      req.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
      req.setRawHeader(QString("Accept-Encoding").toLatin1(),
      QString("gzip,deflate").toLatin1());
      req.setRawHeader(QString("Cache-control").toLatin1(),
      QString("no-cache").toLatin1());
      req.setRawHeader(QString("Pragma").toLatin1(),
      QString("no-cache").toLatin1());
      req.setRawHeader(QString("Accept").toLatin1(),
      QString("/").toLatin1());
      req.setRawHeader(QString("Accept-Language").toLatin1(),
      QString("en-US,en;q=0.5").toLatin1());
      req.setHeader(QNetworkRequest::ContentLengthHeader,
      QVariant(postData.size()).toString());

      //manager->Accessible;
      //qDebug() << manager->configuration();
      reply = manager->post(req,postData);
      connect(reply, SIGNAL(uploadProgress(qint64, qint64)),
      this,SLOT(uploadingProgress(qint64, qint64)));
      connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
      this,SLOT(downloadingProgress(qint64 , qint64 )));
      connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
      this, SLOT(slotError(QNetworkReply::NetworkError)));
      @

      Can you help me?

      thanks

      1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators last edited by

        why do you think it's sent 3 times? Did you sniff the traffic and really verified that it got sent 3 times?

        Also from the code you've posted, it seems that you definitely just send the request once.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • A
          antonio last edited by

          Hi raven,

          I've been sniffing with wireshark and I've seen that when I've sent my post with Poster (Firefox plugin), there are some kind of handshaking. So I think that I need to handle in my client, this is only a theory.

          Regards.

          1 Reply Last reply Reply Quote 0
          • A
            antonio last edited by

            H

            1 Reply Last reply Reply Quote 0
            • First post
              Last post