summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qnetworkreply/tst_qnetworkreply.cpp')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 782d533bbf..a456d15472 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -378,6 +378,8 @@ private Q_SLOTS:
void dontInsertPartialContentIntoTheCache();
+ void httpUserAgent();
+
// NOTE: This test must be last!
void parentingRepliesToTheApp();
};
@@ -1601,6 +1603,11 @@ void tst_QNetworkReply::getFromHttp()
// only compare when the header is set.
if (reply->header(QNetworkRequest::ContentLengthHeader).isValid())
QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size());
+
+ // We know our internal server is apache..
+ if (qstrcmp(QTest::currentDataTag(), "success-internal") == 0)
+ QVERIFY(reply->header(QNetworkRequest::ServerHeader).toString().contains("Apache"));
+
QCOMPARE(reply->readAll(), reference.readAll());
}
@@ -2511,7 +2518,7 @@ void tst_QNetworkReply::ioGetFromFile()
QNetworkRequest request(QUrl::fromLocalFile(file.fileName()));
QNetworkReplyPtr reply = manager.get(request);
- QVERIFY(reply->isFinished()); // a file should immediatly be done
+ QVERIFY(reply->isFinished()); // a file should immediately be done
DataReader reader(reply);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -2801,7 +2808,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
void tst_QNetworkReply::ioGetFromHttpWithAuthSynchronous()
{
// verify that we do not enter an endless loop with synchronous calls and wrong credentials
- // the case when we succed with the login is tested in ioGetFromHttpWithAuth()
+ // the case when we succeed with the login is tested in ioGetFromHttpWithAuth()
QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt"));
request.setAttribute(
@@ -2910,7 +2917,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
void tst_QNetworkReply::ioGetFromHttpWithProxyAuthSynchronous()
{
// verify that we do not enter an endless loop with synchronous calls and wrong credentials
- // the case when we succed with the login is tested in ioGetFromHttpWithAuth()
+ // the case when we succeed with the login is tested in ioGetFromHttpWithAuth()
QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129);
QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"));
@@ -6262,7 +6269,7 @@ void tst_QNetworkReply::httpAbort()
QCOMPARE(reply->error(), QNetworkReply::OperationCanceledError);
QVERIFY(reply->isFinished());
- // Abort immediatly after the get()
+ // Abort immediately after the get()
QNetworkReplyPtr reply2 = manager.get(request);
connect(reply2, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
reply2->abort();
@@ -6312,6 +6319,25 @@ void tst_QNetworkReply::dontInsertPartialContentIntoTheCache()
QCOMPARE(memoryCache->m_insertedUrls.count(), 0);
}
+void tst_QNetworkReply::httpUserAgent()
+{
+ QByteArray response("HTTP/1.0 200 OK\r\n\r\n");
+ MiniHttpServer server(response);
+ server.doClose = true;
+
+ QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
+ request.setHeader(QNetworkRequest::UserAgentHeader, "abcDEFghi");
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(reply->isFinished());
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(server.receivedData.contains("\r\nUser-Agent: abcDEFghi\r\n"));
+}
+
+
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
{