QNetworkReply long request - 399 code or incomplete data
Hi
I am experiencing a problem of long request with code 399. It is something randomly but occurs in 90% of requests. The data is XML which I need to parse.
If no 399 code I get part of my xml respond. The xml is incomplete.
Thoughts ??
This is how I make a connections and check for errors, I use all signals to make sure is all good.
Code:
connect(_reply,SIGNAL(finished()),this, SLOT(postFinished()));
connect(_reply,SIGNAL(readyRead()),this, SLOT(readyReadData()));
connect(_reply,SIGNAL(error(QNetworkReply::NetworkError)),this, SLOT(postError(QNetworkReply::NetworkError)));
connect(_reply,SIGNAL(sslErrors ( const QList<QSslError> & )),this, SLOT(postSslErrors( const QList<QSslError> &)));
The data a get from readyReadData() so I should have it all there if no error and requests is finished , right ?
Code:
void FormPost::readyReadData() {
INFO_DEBUGME("http data are ready");
data = _reply->readAll();
INFO_DEBUGME(data);
if(_loop.isRunning())
_loop.exit();
}
The xml is fine too, all browser can parse it correctly. Also if the xml data is less, then I get full xml and no error.
I have tried to read a data from QNetworkReply::finished () same thing, incomplete xml data even if QT says
Quote:
After this signal is emitted, there will be no more updates to the reply's data or metadata.
Any ideas ??
Re: QNetworkReply long request - 399 code or incomplete data
I have fixed that changing to Response.ContentType = "application/octet-stream" instead of XML, obviously QT does something wrong there.
Re: QNetworkReply long request - 399 code or incomplete data
QIODevice::readyRead() is signalled when there is data available to be read, not when all the data is ready to be read. To get the entire response in one hit you should readAll() in the finished() signal handler (if there has been no error). You can, if you wish, accumulate portions of the response each time readyRead() is signaled and use finished() only to finalise things (e.g. writing a huge file to disk piece by piece, then closing it).
Since "399" is not a standard HTTP response code we can only assume this is the error returned by QNetworkReply::error(). The error message is self-explanatory:
Quote:
QNetworkReply::ProtocolFailure 399 a breakdown in protocol was detected (parsing error, invalid or unexpected responses, etc.)
This implies that the server is doing something unexpected in the response but we have no information to go on. Did you write the server code too?