I read the document of signal finished() , it does not say the finished() is always emitted. And I read the error() signal:
void QNetworkReply::error(QNetworkReply::NetworkError code) This signal is emitted when the reply detects an error in processing. The finished() signal will probably follow, indicating that the connection is over.
The code parameter contains the code of the error that was detected. Call errorString() to obtain a textual representation of the error condition.
Note: Do not delete the object in the slot connected to this signal. Use deleteLater().
See also error() and errorString().
Does the line The finished() signal will probably follow
mean that, under some conditions, the QNetworkReply does not emit finished() ?
For QNetworkReply error signal we can certainly expect error codes that don't mean broken connection. For instance:
QNetworkReply::ContentNotFoundError 203 the remote content was not found at the server (similar to HTTP error 404)
The connection is definitely not finished yet in the case above. No finish signal emitted.
QNetworkReply::RemoteHostClosedError 2 the remote server closed the connection prematurely, before the entire reply was received and processed
The connection is definitely finished then. And finish signal was emitted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With