0

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.

peak
  • 105,803
  • 17
  • 152
  • 177
Rudolfs Bundulis
  • 11,636
  • 6
  • 33
  • 71
  • I remember digging through the code, and `QNAM` buffers on upload iff 1) the `QIODevice` is sequential, *and* 2) a `Content-Size` header is missing from the network request. IOW: if Qt can't know how big is the data to upload unless it reads it all. Is it your case? – peppe Jan 21 '16 at 09:51
  • @peppe - thanks for the response. Actually (and I'm quite sorry about wasting your time) the data was actually sent - the other party did respond prematurely with 413 (entity too large) and for some reason Wireshark didn't catch this as a valid HTTP request. But I also debugged Qt (since Wireshark gave me the impression that nothing was sent) and Qt works fine - if you set a Content-Length on the request then it just reads from the device and transmits in parallel unitl all the data is read. – Rudolfs Bundulis Jan 22 '16 at 08:53

0 Answers0