diff options
Diffstat (limited to 'tests/auto/httpserver/proxy_server.h')
-rw-r--r-- | tests/auto/httpserver/proxy_server.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/httpserver/proxy_server.h b/tests/auto/httpserver/proxy_server.h new file mode 100644 index 000000000..6be0c4e1a --- /dev/null +++ b/tests/auto/httpserver/proxy_server.h @@ -0,0 +1,42 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifndef PROXY_SERVER_H +#define PROXY_SERVER_H + +#include <QObject> +#include <QTcpServer> + +class ProxyServer : public QObject +{ + Q_OBJECT + +public: + explicit ProxyServer(QObject *parent = nullptr); + void setCredentials(const QByteArray &user, const QByteArray password); + void setCookie(const QByteArray &cookie); + bool isListening(); + void setPort(int port); + +public slots: + void run(); + +private slots: + void handleNewConnection(); + void handleReadReady(); + +signals: + void authenticationSuccess(); + void cookieMatch(); + void requestReceived(); + +private: + int m_port = 5555; + QByteArray m_data; + QTcpServer m_server; + QByteArray m_auth; + QByteArray m_cookie; + bool m_authenticate = false; +}; + +#endif // PROXY_SERVER_H |