Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Http post, sent 3 times
QtWS25 Last Chance

Http post, sent 3 times

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.2k Views
  • 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 Offline
    A Offline
    antonio
    wrote on last edited by
    #1

    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
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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
      0
      • A Offline
        A Offline
        antonio
        wrote on last edited by
        #3

        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
        0
        • A Offline
          A Offline
          antonio
          wrote on last edited by
          #4

          H

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved