I am not sure if the functionality I need isn't something that Qt is just not capable of but it seems that since there are multiple valid use cases maybe I am doing something wrong and someone has already dealt with this.
What I want do to is pretty simple - I want to issue a POST request with a given content length and provide the actual POST contents on the fly from a QIODevice
. QNetworkAccessManager
has a method QNetworkReply * QNetworkAccessManager::post(const QNetworkRequest & request, QIODevice * data)
which seems to be ideal for this. The content length is large (lets assume 8 GB) and it seems that Qt tries to call QIODevice::readData
to obtain all of the data before anything is emitted to the network (at least Wireshark is not showing anything whereas setting a small content length, for example 4, produces the behavior where 4 bytes are read and everything is transmitted). This has lead me to believe that Qt actually wants to buffer all of the POST content. I have explicitly set the QNetworkRequest::DoNotBufferUploadDataAttribute
attribute but that does not change this.
It could be that it actually works like this and there is nothing I can do about it, but in that case, how would huge file upload that simply do not fit in memory work? Anyhow, any feedback from people who have experienced the same problem is welcome while I debug to see if Qt is actually buffering the whole thing.