diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-20 18:48:48 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-22 07:41:12 (GMT) |
commit | fbc94a70f2f539d640c3a7785d11e4d6ebe70b16 (patch) | |
tree | bc4a135fccaef14a282f7822188ff3f42701c203 /tests/auto | |
parent | 5c9581b896f99eda8bd98fa265f9d010e6961dea (diff) | |
download | Qt-fbc94a70f2f539d640c3a7785d11e4d6ebe70b16.zip Qt-fbc94a70f2f539d640c3a7785d11e4d6ebe70b16.tar.gz Qt-fbc94a70f2f539d640c3a7785d11e4d6ebe70b16.tar.bz2 |
[networkselftest] Verify the presence and size of some files on HTTP
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/networkselftest/tst_networkselftest.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 6e07d4a..a4a130a 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -77,6 +77,8 @@ private slots: void ftpProxyServer(); void imapServer(); void httpServer(); + void httpServerFiles_data(); + void httpServerFiles(); void httpsServer(); void httpProxy(); void httpProxyBasicAuth(); @@ -162,7 +164,7 @@ static QString prettyByteArray(const QByteArray &array) static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 4000) { - QTime timer; + QElapsedTimer timer; timer.start(); forever { if (socket->bytesAvailable() >= minBytesAvailable) @@ -639,6 +641,43 @@ void tst_NetworkSelfTest::httpServer() ); } +void tst_NetworkSelfTest::httpServerFiles_data() +{ + QTest::addColumn<QString>("uri"); + QTest::addColumn<int>("size"); + + QTest::newRow("fluke.gif") << "/qtest/fluke.gif" << -1; + QTest::newRow("bigfile") << "/qtest/bigfile" << 519240; + QTest::newRow("rfc3252.txt") << "/qtest/rfc3252.txt" << 25962; + QTest::newRow("protected/rfc3252.txt") << "/qtest/protected/rfc3252.txt" << 25962; + QTest::newRow("completelyEmptyQuery.xq") << "/qtest/qxmlquery/completelyEmptyQuery.xq" << -1; + QTest::newRow("notWellformedViaHttps.xml") << "/qtest/qxmlquery/notWellformedViaHttps.xml" << -1; + QTest::newRow("notWellformed.xml") << "/qtest/qxmlquery/notWellformed.xml" << -1; + QTest::newRow("viaHttp.xq") << "/qtest/qxmlquery/viaHttp.xq" << -1; + QTest::newRow("wellFormedViaHttps.xml") << "/qtest/qxmlquery/wellFormedViaHttps.xml" << -1; + QTest::newRow("wellFormed.xml") << "/qtest/qxmlquery/wellFormed.xml" << -1; +} + +void tst_NetworkSelfTest::httpServerFiles() +{ + QFETCH(QString, uri); + QFETCH(int, size); + + QList<Chat> chat; + chat << Chat::send("HEAD " + QUrl::toPercentEncoding(uri, "/") + " HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Connection: close\r\n" + "Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::skipBytes(1) // HTTP/1.0 or 1.1 reply + << Chat::expect(" 200 "); + if (size != -1) + chat << Chat::discardUntil("\r\nContent-Length: " + QByteArray::number(size) + "\r\n"); + chat << Chat::DiscardUntilDisconnect; + netChat(80, chat); +} + void tst_NetworkSelfTest::httpsServer() { #ifndef QT_NO_OPENSSL |