tests/auto/qnetworkreply/tst_qnetworkreply.cpp
changeset 37 758a864f9613
parent 30 5dc02b23752f
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   287     void getAndThenDeleteObject_data();
   287     void getAndThenDeleteObject_data();
   288     void getAndThenDeleteObject();
   288     void getAndThenDeleteObject();
   289 
   289 
   290     void symbianOpenCDataUrlCrash();
   290     void symbianOpenCDataUrlCrash();
   291 
   291 
       
   292     void qtbug12908compressedHttpReply();
       
   293 
   292     // NOTE: This test must be last!
   294     // NOTE: This test must be last!
   293     void parentingRepliesToTheApp();
   295     void parentingRepliesToTheApp();
   294 };
   296 };
   295 
   297 
   296 QT_BEGIN_NAMESPACE
   298 QT_BEGIN_NAMESPACE
  4272     QCOMPARE(reply->error(), QNetworkReply::NoError);
  4274     QCOMPARE(reply->error(), QNetworkReply::NoError);
  4273 
  4275 
  4274     QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(598));
  4276     QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(598));
  4275 }
  4277 }
  4276 
  4278 
       
  4279 // TODO:
       
  4280 // Prepare a gzip that has one chunk that expands to the size mentioned in the bugreport.
       
  4281 // Then have a custom HTTP server that waits after this chunk so the returning gets
       
  4282 // triggered.
       
  4283 void tst_QNetworkReply::qtbug12908compressedHttpReply()
       
  4284 {
       
  4285     QString header("HTTP/1.0 200 OK\r\nContent-Encoding: gzip\r\nContent-Length: 63\r\n\r\n");
       
  4286 
       
  4287     // dd if=/dev/zero of=qtbug-12908 bs=16384  count=1 && gzip qtbug-12908 && base64 -w 0 qtbug-12908.gz
       
  4288     QString encodedFile("H4sICDdDaUwAA3F0YnVnLTEyOTA4AO3BMQEAAADCoPVPbQwfoAAAAAAAAAAAAAAAAAAAAIC3AYbSVKsAQAAA");
       
  4289     QByteArray decodedFile = QByteArray::fromBase64(encodedFile.toAscii());
       
  4290 
       
  4291     MiniHttpServer server(header.toAscii() + decodedFile);
       
  4292     server.doClose = true;
       
  4293 
       
  4294     QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
       
  4295     QNetworkReplyPtr reply = manager.get(request);
       
  4296 
       
  4297     connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
       
  4298     QTestEventLoop::instance().enterLoop(10);
       
  4299     QVERIFY(!QTestEventLoop::instance().timeout());
       
  4300 
       
  4301     QCOMPARE(reply->error(), QNetworkReply::NoError);
       
  4302 }
  4277 
  4303 
  4278 
  4304 
  4279 // NOTE: This test must be last testcase in tst_qnetworkreply!
  4305 // NOTE: This test must be last testcase in tst_qnetworkreply!
  4280 void tst_QNetworkReply::parentingRepliesToTheApp()
  4306 void tst_QNetworkReply::parentingRepliesToTheApp()
  4281 {
  4307 {