[Qt-interest] weird problem with QNetworkAccessManager and posting-requests

Benjamin bebl at mageta.org
Tue Apr 26 20:28:50 CEST 2011


Am 25.04.2011 06:44, schrieb Mandeep Sandhu:
> I'm shooting in the dark here....but do you need to set the content
> length explicitly?
>
> I'm using the post method to send off a request using QT 4.6.2 on and
> embedded system (and 4.7.1 on Desktop) and it works w/o setting the
> content length. I guess QT would already be doing that for you.
>
> Also, how about using a QUrl to make your post query string and then
> converting it into a QByteArray (using QUrl::toEncoded())...that way
> you're assured that the query string is created and encoded properly.
>
> What QT version are you working with? Also, could this be your
> webserver specific issue? Have your tried another webserver?
>
> -mandeep

I'm using Qt 4.7.2 (gentoo-linux).

I just have rewritten the program as you suggested and yes, I did a 
little unnecessary work, but the problem persists. The code looks 
currently like this:

netManager = new QNetworkAccessManager(this);
connect(netManager, SIGNAL(finished(QNetworkReply*)), this,SLOT(replyFinished(QNetworkReply*)));
QNetworkRequest  request(QUrl("http://www.zlug.org/~bebl/php/swformtest/swloginform.php"));
QUrl  post;
post.addQueryItem("SCX","1024");
post.addQueryItem("SCY","768");
post.addQueryItem("WSCX","1008");
post.addQueryItem("WSCY","593");
post.addQueryItem("FORM_USERNAME",username);  // possible none-Latin-1-Chars
post.addQueryItem("FORM_PASS",password);  // possible none-Latin-1-Chars
post.addQueryItem("LOGON","Login");
post.addQueryItem("NOREFRESH","1");
post.addQueryItem("NOGFX","1");
debugOutput("LoginThread::run:  ascertained  post-data:  "+post.encodedQuery());
netManager->post(request,  post.encodedQuery());

As you can see, I currently do only the absolute necessary. (my self-written wwwEncoder was built according the rules of http://tools.ietf.org/html/rfc1738 .. so it should work the same way as QUrl ;) ). I also changed the webserver, as you can see.

The previously described effect is the same, in 1 out of 5 posts, the fin-flag is set in the post-request and the post-data is added twice. After this, the finished-SIGNAL is never sent and the thread is dead-locked.




More information about the Qt-interest-old mailing list