Results 1 to 2 of 2

Thread: HTTP Post from QNetworkAccessManager - no data sent

  1. #1
    Join Date
    Apr 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: HTTP Post from QNetworkAccessManager - no data sent

    I'm trying to send a post request, any which way. However, no bytes are getting sent, according to wireshark. I understand that the following isn't going to produce valid output, but it should produce some bytes, right? I've had no problems with networkAccessManager and http get().

    My fundamental question: under what conditions are no bytes sent?

    Here's what I'm trying, which yields nothing (qDebugs() in the slots() don't get triggered, and I get a 10s timeout).

    QString crlf="\r\n";
    QByteArray request;
    request.append("Content-Disposition: form-data; name=\"first_thing\"");
    request.append(crlf.toAscii());
    request.append("whatever");
    request.append(crlf.toAscii());
    manager.reset(new QNetworkAccessManager(this));
    connect(manager.get(),SIGNAL(finished(QNetworkRepl y *)),this,SLOT(readData(QNetworkReply *)));
    QNetworkRequest netRequest;
    netRequest.setUrl(QUrl(url));
    QString contentType="multipart/form-data; boundary=---------------------------1234cfa";
    netRequest.setRawHeader("Host", "whatever.com");
    netRequest.setHeader(QNetworkRequest::ContentTypeH eader, contentType.toAscii());
    netRequest.setHeader(QNetworkRequest::ContentLengt hHeader, QVariant(request.size()).toString());
    netReply.reset(manager->post(netRequest,request));
    qDebug() << "Done sending";
    qDebug() << "Size: " << netReply->size();


    Added after 6 minutes:


    I've tried http://www.tuckdesign.com/sources/Qt as well, with no packets sent.

    Most frustrating thing here is that I don't know what to check to start debugging. I've attached to the error signal as well:

    connect(reply.get(), SIGNAL(error(QNetworkReply::NetworkError)),
    this, SLOT(slotError(QNetworkReply::NetworkError)));

    with no luck.

    The .reset() above is me using boost::shared_ptr for fun. I've taken it out, and it does the same thing.
    Last edited by secureboot; 13th April 2011 at 07:20. Reason: clarification

  2. #2
    Join Date
    Apr 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: HTTP Post from QNetworkAccessManager - no data sent

    Object that was doing the posting was getting deleted early, causing this problem.

Similar Threads

  1. POST and QNetworkAccessManager
    By hakermania in forum Newbie
    Replies: 1
    Last Post: 13th February 2011, 01:05
  2. Http post
    By Max123 in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2010, 14:43
  3. QNetworkAccessManager::post() never returns
    By danc81 in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2009, 10:13
  4. QNetworkAccessManager double post
    By QPlace in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2009, 05:44
  5. How do I send data with http post request?
    By Morea in forum Qt Programming
    Replies: 13
    Last Post: 21st January 2009, 23:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.