Http post, sent 3 times



  • 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


  • Moderators

    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.



  • 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.



  • H


Log in to reply
 

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