QHttp should work fine. It has a dataSendProgress() signal.
QHttp should work fine. It has a dataSendProgress() signal.
Ok, i thought to use it from the very beginning, I didn't just because I read the following in the Qt documentation: "This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code."
Yes, that's true but your requirement is somewhat different from what people use HTTP for in their apps. I don't know why you don't want to wait for the server's response -- you might get a 404 or 500 or some other fault. I think it's worth knowing if your request went to /dev/null or not.
I may want to upload some data or send logout. Sometimes it takes a several seconds (depending on connection, network problems etc). In my application it is more important to proceed quickly than know whether the data was uploaded or not. I don't care much how successful was logout sent to some third party server, but I want my app to be closed quickly, so users won't need to wait until slow server responds.
So why do you want to send the logout at all if you don't care if it works or not?
I send logout because it is better to send than not to send (third party server recommends to send it). Also I upload some data that may be useful, but if it fails it is not critical. Moreover if logout fails in most cases I can't do anything with that, so result can be only logged somewhere and it is not that important for users. But as long as it doesn't make my application inconvenient to users I think it is better to call logout and upload all the data that may be useful.
Then don't wait for anything, send the data and start closing your app. With a bit of luck, the request will go through. If not then you don't care anyway... If you do care, then wait a predefined amount of time for a response and if you don't get it during this period, abandon the request and close your app.
Well, eventually I came to the same approach. I can afford it to wait for let's say 1 second, the only bad side is that waiting for data sent in most cases would take less time, but with this approach I still have to wait 1 second that is for the worst case. My question: is there any place where I can ask to add this feature? To my mind having dataSent signal would be useful.
Qt is open-source, add the feature yourself. It should be just a couple lines of code.
Bookmarks