PDA

View Full Version : QNetworkReply::uploadProgress finishes immediately



peppermg
24th March 2010, 13:05
I am using QNetworkAccessManager::post to upload files to a webserver, and everything is working except QNetworkReply::uploadProgress returns almost instantly that the upload has finished when in fact it is far from finished. There seems to be a bug when using HTTPS http://qt.nokia.com/developer/task-tracker/index_html?method=entry&id=249585, although I am using HTTP. Any insight would be helpful, Thanks.

peppermg
24th March 2010, 14:26
Did some more research and found this on the Qt-interest list. http://lists.trolltech.com/pipermail/qt-interest/2009-September/012265.html


> Hi,
>
> Does anyone use QNetworkAccessManager and QNetworkReply? I've some odd
> behaviour with them in that the uploadProgress() event is fired and
> has no real baring on the actual progress of the upload.

That's a bug and has been fixed.

I don't remember if we could fix it for the 4.5.x series, though. I'm certain
it's fixed for the upcoming 4.6.0.

What happens is that the QNetworkReply class emits the signal when it writes
to its backend (the private QHttpNetworkConnection class). However, since
QTcpSocket's outgoing buffer is not bounded, QHttpNetworkConnection ends up
transferring all bytes from your source data directly into the socket buffer.
So we buffer everything in memory and then send as fast as the kernel socket
can send.

The fix was to control the buffer size and stop reading from the user once we
reach a certain threshold.
--
Thiago Macieira - thiago.macieira (AT) nokia.com
Senior Product Manager - Nokia, Qt Development Frameworks
Sandakerveien 116, NO-0402 Oslo, Norway


Can anyone confirm if this bug has been fixed? I can't find any information about it. BTW I am using 4.6.0.

peppermg
26th March 2010, 17:19
Still have not been able to find out what is going on. Something else I have observed is occasionally when starting an upload the progress will jump to what seems like a random percentage e.g. (81%) then wait for the actual upload to catch up and continue on seemingly normal, though this only seems to happen for the first upload if you start multiple, and it is not reliably repeatable.