Results 1 to 3 of 3

Thread: QNetworkReply long request - 399 code or incomplete data

  1. #1
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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.

    Qt Code:
    1. connect(_reply,SIGNAL(finished()),this, SLOT(postFinished()));
    2. connect(_reply,SIGNAL(readyRead()),this, SLOT(readyReadData()));
    3. connect(_reply,SIGNAL(error(QNetworkReply::NetworkError)),this, SLOT(postError(QNetworkReply::NetworkError)));
    4. connect(_reply,SIGNAL(sslErrors ( const QList<QSslError> & )),this, SLOT(postSslErrors( const QList<QSslError> &)));
    To copy to clipboard, switch view to plain text mode 

    The data a get from readyReadData() so I should have it all there if no error and requests is finished , right ?

    Qt Code:
    1. void FormPost::readyReadData() {
    2. INFO_DEBUGME("http data are ready");
    3.  
    4. data = _reply->readAll();
    5.  
    6. INFO_DEBUGME(data);
    7.  
    8. if(_loop.isRunning())
    9. _loop.exit();
    10. }
    To copy to clipboard, switch view to plain text mode 
    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
    After this signal is emitted, there will be no more updates to the reply's data or metadata.
    Any ideas ??
    Last edited by migel; 10th August 2011 at 12:31.

  2. #2
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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:
    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?

Similar Threads

  1. QNetworkReply: how to know when data is sent?
    By mentalmushroom in forum Qt Programming
    Replies: 17
    Last Post: 24th June 2011, 08:22
  2. X Error: BadRequest (invalid request code or no such operation) 1
    By Luc4 in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 18th April 2011, 14:40
  3. Replies: 1
    Last Post: 8th March 2011, 06:27
  4. Code Review Request for first small application
    By RurouniJones in forum Newbie
    Replies: 0
    Last Post: 22nd March 2010, 08:22
  5. How do I send data with http post request?
    By Morea in forum Qt Programming
    Replies: 13
    Last Post: 21st January 2009, 22:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.