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