Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-19480

QNetworkReply incorrectly report ContentReSendError for unrelated QNetworkReply

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.8.2
    • 4.7.0, 4.7.3
    • Network
    • None
    • Qt 4.7.0
      Windows 7 x64
    • b754deb055db1b3d74f4ecaed38fa7e59fdcd877; 2cfc2a2e9af97a2799e76868e4c6b302d55266e0

    Description

      When using QNetworkAccessManager and disable buffering of upload data, after sending the first request, if the server side closes the connection, and the client side tries to send another request, it will get ContentReSendError via QNetworkReply.
      Here is a test case:

      #include <QNetworkAccessManager>
      #include <QNetworkRequest>
      #include <QNetworkReply>
      #include <QDebug>
      #include <QCoreApplication>
      #include <QUrl>
      #include <QTextStream>
      using namespace std;
      
      int main(int argc,char** argv)
      {
      	   QTextStream in(stdin,QIODevice::ReadOnly);
      	   QCoreApplication loop(argc,argv);
      	   QNetworkAccessManager manager;
      	   QByteArray content("123");
      	   QNetworkRequest request(QUrl("http://www.yahoo.com"));
      	   request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute,QVariant(true));
      	   while(1)
      	   {
      			   QNetworkReply* reply=manager.post(request,content);
      			   QObject::connect(reply,SIGNAL(finished()),&loop,SLOT(quit()));
      			   loop.exec();
      			   QNetworkReply::NetworkError error=reply->error();
      			   if(error!=QNetworkReply::NoError)
      					   qDebug()<<"error: "<<error;
      			   else
      					   qDebug()<<"success";
      			   reply->deleteLater();
      			   in.readLine();
      	   }
      }
      
      

      To test the above code, after seeing the "success" message, wait for about 30 seconds for the server side to close the connection, and then press enter to send the second request. An error message "error: 205" should then appear.

      Since the connection is closed before the 2nd request is sent, instead of reporting ContentReSendError, it should have create another connection.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            xcm Martin Petersson (Inactive)
            someone someone
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes