summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/shared
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/shared')
-rw-r--r--tests/auto/declarative/shared/testhttpserver.cpp11
-rw-r--r--tests/auto/declarative/shared/testhttpserver.h2
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp
index 6c9d849..490fc95 100644
--- a/tests/auto/declarative/shared/testhttpserver.cpp
+++ b/tests/auto/declarative/shared/testhttpserver.cpp
@@ -115,6 +115,11 @@ void TestHTTPServer::addAlias(const QString &filename, const QString &alias)
aliases.insert(filename, alias);
}
+void TestHTTPServer::addRedirect(const QString &filename, const QString &redirectName)
+{
+ redirects.insert(filename, redirectName);
+}
+
bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &body)
{
m_hasFailed = false;
@@ -230,6 +235,12 @@ void TestHTTPServer::readyRead()
bool TestHTTPServer::reply(QTcpSocket *socket, const QByteArray &fileName)
{
+ if (redirects.contains(fileName)) {
+ QByteArray response = "HTTP/1.1 302 Found\r\nContent-length: 0\r\nContent-type: text/html; charset=UTF-8\r\nLocation: " + redirects[fileName].toUtf8() + "\r\n\r\n";
+ socket->write(response);
+ return true;
+ }
+
for (int ii = 0; ii < dirs.count(); ++ii) {
QString dir = dirs.at(ii).first;
Mode mode = dirs.at(ii).second;
diff --git a/tests/auto/declarative/shared/testhttpserver.h b/tests/auto/declarative/shared/testhttpserver.h
index 2a8709f..178122d 100644
--- a/tests/auto/declarative/shared/testhttpserver.h
+++ b/tests/auto/declarative/shared/testhttpserver.h
@@ -62,6 +62,7 @@ public:
bool hasFailed() const;
void addAlias(const QString &filename, const QString &aliasName);
+ void addRedirect(const QString &filename, const QString &redirectName);
private slots:
void newConnection();
@@ -83,6 +84,7 @@ private:
bool m_hasFailed;
QHash<QString,QString> aliases;
+ QHash<QString,QString> redirects;
QTcpServer server;
};