PDA

View Full Version : How to make QHttp detect a disconnect?



gfunk
7th February 2007, 01:11
I have some code downloading some file via QHttp, it works fine normally. WinXP, Qt4.2

However, if I disconnect while the download is in progress (e.g., disconnect the network cable), my QHttp object (immediately) gives me a requestFinished(int, bool) signal but says there is no error (ie the bool parameter is false). I also get a done() signal indicating no error (ie the bool parameter is also false). So my code assumes the file is complete when it is actually just partially downloaded, and then operates on a corrupt file.

Is there a way in Qt to detect this error case properly?

wysota
7th February 2007, 10:07
You can compare the size of the file to the size announced in the response header. You can't really tell between a "good" and "bad" disconnect - in both cases the connection is broken.