1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QABSTRACTHTTPSERVER_P_H
6#define QABSTRACTHTTPSERVER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of QHttpServer. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17
18#include <QtHttpServer/qabstracthttpserver.h>
19#include <QtHttpServer/qthttpserverglobal.h>
20#include <QtHttpServer/qhttpserverconfiguration.h>
21#include <QtHttpServer/private/qhttpserverrequestfilter_p.h>
22
23#include <private/qobject_p.h>
24
25#include <QtCore/qcoreapplication.h>
26#include <QtCore/qtimer.h>
27
28#include <vector>
29
30#if defined(QT_WEBSOCKETS_LIB)
31#include <QtWebSockets/qwebsocketserver.h>
32#endif // defined(QT_WEBSOCKETS_LIB)
33
34#if QT_CONFIG(ssl)
35#include <QtNetwork/qhttp2configuration.h>
36#endif
37
38QT_BEGIN_NAMESPACE
39
40class QHttpServerRequest;
41
42class QAbstractHttpServerPrivate: public QObjectPrivate
43{
44public:
45 Q_DECLARE_PUBLIC(QAbstractHttpServer)
46
47 QAbstractHttpServerPrivate();
48
49#if defined(QT_WEBSOCKETS_LIB)
50 QWebSocketServer websocketServer {
51 QCoreApplication::applicationName() + QLatin1Char('/') + QCoreApplication::applicationVersion(),
52 QWebSocketServer::NonSecureMode
53 };
54#endif // defined(QT_WEBSOCKETS_LIB)
55
56 void handleNewConnections();
57 bool verifyThreadAffinity(const QObject *contextObject) const;
58
59#if QT_CONFIG(localserver)
60 void handleNewLocalConnections();
61#endif
62
63 void createHttp1Handler(QIODevice *socket);
64#if QT_CONFIG(ssl) && QT_CONFIG(http)
65 void createHttp2Handler(QIODevice *socket);
66#endif
67 void restartHeartbeatTimer();
68
69#if defined(QT_WEBSOCKETS_LIB)
70 mutable bool handlingWebSocketUpgrade = false;
71 struct WebSocketUpgradeVerifier
72 {
73 QPointer<const QObject> context;
74 QtPrivate::SlotObjUniquePtr slotObject;
75 };
76 std::vector<WebSocketUpgradeVerifier> webSocketUpgradeVerifiers;
77#endif // defined(QT_WEBSOCKETS_LIB)
78#if QT_CONFIG(ssl)
79 QHttp2Configuration h2Configuration;
80#endif
81 QHttpServerConfiguration configuration;
82 QHttpServerRequestFilter requestFilter;
83 QTimer heartbeatTimer;
84};
85
86QT_END_NAMESPACE
87
88#endif // QABSTRACTHTTPSERVER_P_H
89

source code of qthttpserver/src/httpserver/qabstracthttpserver_p.h