Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does QNetworkReply always emit finished()?

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() ?

like image 697
zzy Avatar asked Oct 31 '22 23:10

zzy


1 Answers

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.

like image 154
Alexander V Avatar answered Nov 10 '22 17:11

Alexander V