summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorØystein Heskestad <oystein.heskestad@qt.io>2022-03-30 12:22:22 +0200
committerØystein Heskestad <oystein.heskestad@qt.io>2022-04-23 01:19:09 +0200
commit6c144d5023c26fa1a7a30ddafa27972266b0bc44 (patch)
tree04f4dd05a71129582ff0834dc9ca40d31ee65caf
parentbfe4011e7077ecf940f8c89dee44c8cea88124b3 (diff)
Add to module documentation
Task-number: QTBUG-100481 Change-Id: I7f80feb2180c616586138f721fab1cf50ee44cbb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
-rw-r--r--doc/afterrequest-example.qdoc40
-rw-r--r--doc/config/qthttpserver.qdocconf50
-rw-r--r--doc/examples.qdoc34
-rw-r--r--doc/external-resources.qdoc36
-rw-r--r--doc/images/browserwindow.pngbin0 -> 19241 bytes
-rw-r--r--doc/index.qdoc58
-rw-r--r--doc/overview.qdoc67
-rw-r--r--doc/qthttpserver-module.qdoc58
-rw-r--r--doc/simple-example.qdoc41
-rw-r--r--src/httpserver/CMakeLists.txt4
-rw-r--r--src/httpserver/qabstracthttpserver.cpp48
-rw-r--r--src/httpserver/qhttpserver.cpp34
-rw-r--r--src/httpserver/qhttpserverfutureresponse.cpp9
-rw-r--r--src/httpserver/qhttpserverrequest.cpp74
-rw-r--r--src/httpserver/qhttpserverresponder.cpp20
-rw-r--r--src/httpserver/qhttpserverresponse.cpp94
-rw-r--r--src/httpserver/qhttpserverrouter.cpp18
-rw-r--r--src/httpserver/qhttpserverrouterrule.cpp26
-rw-r--r--src/sslserver/qsslserver.cpp28
19 files changed, 708 insertions, 31 deletions
diff --git a/doc/afterrequest-example.qdoc b/doc/afterrequest-example.qdoc
new file mode 100644
index 0000000..66bce70
--- /dev/null
+++ b/doc/afterrequest-example.qdoc
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtHttpServer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\ingroup qthttpserver-examples
+\title AfterRequest Example
+\brief Example of the usage of \c afterRequest().
+\image browserwindow.png
+
+This example shows how to use the \c afterRequest() function of the QHttpServer
+to change the QHttpServerResponse object after it has been handled by the
+\c route() function. It demonstrates how HTTP headers can be added to the
+response.
+
+\example afterrequest
+*/
diff --git a/doc/config/qthttpserver.qdocconf b/doc/config/qthttpserver.qdocconf
new file mode 100644
index 0000000..ab8fcd3
--- /dev/null
+++ b/doc/config/qthttpserver.qdocconf
@@ -0,0 +1,50 @@
+include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
+include($QT_INSTALL_DOCS/global/externalsites.qdocconf)
+
+
+project = QtHttpServer
+description = Qt Lightweight HTTP Server Reference Documentation
+version = $QT_VERSION
+
+depends += qtcore qtnetwork qtdoc qmake qtwebsockets
+
+headerdirs += \
+ ../../src/httpserver \
+ ../../src/sslserver
+
+sourcedirs += .. \
+ ../../src/httpserver \
+ ../../src/sslserver
+
+exampledirs += \
+ ../../examples/httpserver/
+
+imagedirs += ../images
+
+examplesinstallpath =
+
+
+defines += QT_WEBSOCKETS_LIB
+
+
+
+qhp.projects = QtHttpServer
+
+qhp.QtHttpServer.file = qthttpserver.qhp
+qhp.QtHttpServer.namespace = org.qt-project.qthttpserver.$QT_VERSION_TAG
+qhp.QtHttpServer.virtualFolder = QtHttpServer
+qhp.QtHttpServer.indexTitle = Qt HTTP Server
+qhp.QtHttpServer.indexRoot =
+
+qhp.QtHttpServer.subprojects = classes examples
+qhp.QtHttpServer.subprojects.classes.title = C++ Classes
+qhp.QtHttpServer.subprojects.classes.indexTitle = Qt HTTP Server Classes
+qhp.QtHttpServer.subprojects.classes.selectors = class fake:headerfile
+qhp.QtHttpServer.subprojects.classes.sortPages = true
+qhp.QtHttpServer.subprojects.examples.title = Examples
+qhp.QtHttpServer.subprojects.examples.indexTitle = Qt HTTP Server Examples
+qhp.QtHttpServer.subprojects.examples.selectors = fake:example
+qhp.QtHttpServer.subprojects.examples.sortPages = true
+
+# Fail the documentation build if there are more warnings than the limit
+warninglimit = 0
diff --git a/doc/examples.qdoc b/doc/examples.qdoc
new file mode 100644
index 0000000..2032263
--- /dev/null
+++ b/doc/examples.qdoc
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtHttpServer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\group qthttpserver-examples
+\title Qt HTTP Server Examples
+\brief Examples of how to use the QtHttpServer module
+
+The examples below can be used as a guide to using the \l{QtHttpServer} API.
+*/
diff --git a/doc/external-resources.qdoc b/doc/external-resources.qdoc
new file mode 100644
index 0000000..2a81543
--- /dev/null
+++ b/doc/external-resources.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \externalpage https://datatracker.ietf.org/doc/html/rfc2616
+ \title RFC 2616
+*/
+
+/*!
+ \externalpage https://datatracker.ietf.org/doc/html/rfc7617
+ \title RFC 7617
+*/
diff --git a/doc/images/browserwindow.png b/doc/images/browserwindow.png
new file mode 100644
index 0000000..7edc7e6
--- /dev/null
+++ b/doc/images/browserwindow.png
Binary files differ
diff --git a/doc/index.qdoc b/doc/index.qdoc
new file mode 100644
index 0000000..33cfdd1
--- /dev/null
+++ b/doc/index.qdoc
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qthttpserver-index.html
+ \since 6.4
+ \title Qt HTTP Server
+ \brief Provides a lightweight server implementing the HTTP protocol.
+
+ \section1 Getting Started
+
+ To include the definitions of the module's classes, use the following directive:
+
+ \code
+ #include <QtHttpServer/QtHttpServer>
+ \endcode
+
+ \section1 Licenses
+
+ QtHttpServer is available under commercial licenses from \l{The Qt Company}.
+ In addition, it is available under the \l {GNU General Public License, version 3}.
+ See \l{Qt Licensing} for further details.
+
+ \section1 Reference Documentation
+ \list
+ \li \l{Qt HTTP Server Overview}{Overview}
+ \li \l{Qt HTTP Server C++ Classes}{C++ Classes}
+ \endlist
+
+ \section1 Examples
+
+ The module provides the following \l{Qt HTTP Server Examples}{Examples} as a guide to using
+ the API.
+*/
diff --git a/doc/overview.qdoc b/doc/overview.qdoc
new file mode 100644
index 0000000..f70044b
--- /dev/null
+++ b/doc/overview.qdoc
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qthttpserver-overview.html
+\title Qt HTTP Server Overview
+\brief Provides insight into the HTTP protocol and the QtHttpServer module.
+
+Qt HTTP Server supports building an HTTP server into an application. It
+provides an implementation of the server side of the HTTP protocol, and also
+provides security through Transport Layer Security. Because it is designed for
+embedding in applications to expose things in a trusted network, and doesn't
+have robustness/security as a goal, it is not suitable for being
+internet-facing.
+
+\section1 How does it work?
+
+Qt HTTP Server provides building blocks for embedding a lightweight HTTP server
+in an application. There are classes for the messages sent and received, and
+for the different parts of an HTTP server.
+
+\section1 How do you use it?
+
+An HTTP server can created by subclassing the QAbstractHttpServer class, and
+overriding the \c handleRequest() function. The QAbstractHttpServer class
+provides functions for listening to incoming ports or binding to an existing
+QTcpServer. Dispatching to lambdas based on incoming URLs can be simplified
+by using the QHttpServerRouter class.
+
+This can be simplified even further by using the QHttpServer class.
+The QHttpServer class is a subclass of QAbstractHttpServer, and defines an
+overloaded route function to bind lambdas to different incoming URLs,
+and an afterRequest function to process the response further.
+
+When security is needed and you have Qt compiled with support for TLS,
+you can bind QAbstractHttpServer and its subclasses to a QSslServer object,
+providing Transport Layer Security handling, turning it into an HTTPS server.
+
+\section2 Related Information
+\list
+\li \l{RFC 2616}
+\endlist
+*/
diff --git a/doc/qthttpserver-module.qdoc b/doc/qthttpserver-module.qdoc
new file mode 100644
index 0000000..60cb061
--- /dev/null
+++ b/doc/qthttpserver-module.qdoc
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \module QtHttpServer
+ \title Qt HTTP Server C++ Classes
+ \ingroup modules
+ \qtcmakepackage HttpServer
+ \qtvariable httpserver
+ \since 6.4
+ \brief List of C++ classes that provide HTTP server framework.
+
+ To use these classes in your application, use the following include
+ statement:
+
+ \code
+ #include <QtHttpServer/QtHttpServer>
+ \endcode
+
+ To link against this library with CMake, add the following to your
+ CMakeLists.txt file:
+
+ \code
+ find_package(Qt6 COMPONENTS HttpServer)
+ target_link_libraries(<project name> PUBLIC Qt::HttpServer)
+ \endcode
+
+ If, on the other hand, you are using \l qmake, add this to your \c .pro
+ file:
+
+ \code
+ QT += httpserver
+ \endcode
+
+*/
diff --git a/doc/simple-example.qdoc b/doc/simple-example.qdoc
new file mode 100644
index 0000000..ab55b4d
--- /dev/null
+++ b/doc/simple-example.qdoc
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtHttpServer module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\ingroup qthttpserver-examples
+\title Simple Example
+\brief Simple example of how to set up an HTTP server.
+\image browserwindow.png
+
+This example shows how to set up a server using the QHttpServer class.
+The server is bound to an incoming port using the \c listen() function, and the
+\c route() function is used to add a handler for each of several different
+incoming URLs. For one of the URLs, "/auth", \l{RFC 7617}{Basic HTTP
+Authentication} is used.
+
+\example simple
+*/
diff --git a/src/httpserver/CMakeLists.txt b/src/httpserver/CMakeLists.txt
index 7a79bb6..8e290d9 100644
--- a/src/httpserver/CMakeLists.txt
+++ b/src/httpserver/CMakeLists.txt
@@ -52,3 +52,7 @@ qt_internal_extend_target(HttpServer CONDITION TARGET Qt::Concurrent
PUBLIC_LIBRARIES
Qt::Concurrent
)
+
+qt_internal_add_docs(HttpServer
+ ../../doc/config/qthttpserver.qdocconf
+)
diff --git a/src/httpserver/qabstracthttpserver.cpp b/src/httpserver/qabstracthttpserver.cpp
index 1695ede..ae2e374 100644
--- a/src/httpserver/qabstracthttpserver.cpp
+++ b/src/httpserver/qabstracthttpserver.cpp
@@ -45,10 +45,16 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcHttpServer, "qt.httpserver")
+/*!
+ \internal
+*/
QAbstractHttpServerPrivate::QAbstractHttpServerPrivate()
{
}
+/*!
+ \internal
+*/
void QAbstractHttpServerPrivate::handleNewConnections()
{
Q_Q(QAbstractHttpServer);
@@ -72,6 +78,9 @@ void QAbstractHttpServerPrivate::handleNewConnections()
}
}
+/*!
+ \internal
+*/
void QAbstractHttpServerPrivate::handleReadyRead(QTcpSocket *socket,
QHttpServerRequest *request)
{
@@ -121,10 +130,26 @@ void QAbstractHttpServerPrivate::handleReadyRead(QTcpSocket *socket,
socket->deleteLater();
}
+/*!
+ \class QAbstractHttpServer
+ \inmodule QtHttpServer
+ \brief API to subclass to implement an HTTP server.
+
+ Subclass this class and override \c handleRequest() to create an HTTP
+ server. Use \c listen() or \c bind() to start listening to incoming
+ connections.
+*/
+
+/*!
+ Creates an instance of QAbstractHttpServer with the parent \a parent.
+*/
QAbstractHttpServer::QAbstractHttpServer(QObject *parent)
: QAbstractHttpServer(*new QAbstractHttpServerPrivate, parent)
{}
+/*!
+ \internal
+*/
QAbstractHttpServer::QAbstractHttpServer(QAbstractHttpServerPrivate &dd, QObject *parent)
: QObject(dd, parent)
{
@@ -233,7 +258,7 @@ QVector<QTcpServer *> QAbstractHttpServer::servers() const
#if defined(QT_WEBSOCKETS_LIB)
/*!
- \fn QAbstractHttpServer::newConnection
+ \fn QAbstractHttpServer::newWebSocketConnection()
This signal is emitted every time a new WebSocket connection is
available.
@@ -272,12 +297,33 @@ QWebSocket *QAbstractHttpServer::nextPendingWebSocketConnection()
}
#endif
+/*!
+ \internal
+*/
QHttpServerResponder QAbstractHttpServer::makeResponder(const QHttpServerRequest &request,
QTcpSocket *socket)
{
return QHttpServerResponder(request, socket);
}
+/*!
+ \fn QAbstractHttpServer::handleRequest(const QHttpServerRequest &request,
+ QTcpSocket *socket)
+ Overload this function to handle each incoming \a request from \a socket,
+ by examining the \a request and sending the appropriate response back to
+ \a socket. Returns \c true if the \a request was handled. Otherwise,
+ returns \c false. If returning \c false, the \c missingHandler() signal
+ will be emitted.
+*/
+
+/*!
+ \fn QAbstractHttpServer::missingHandler(const QHttpServerRequest &request, QTcpSocket *socket)
+
+ This signal is emitted whenever \c handleRequest() returns \c false.
+ The \a request and \a socket parameters are the same as \c handleRequest()
+ was called with.
+*/
+
#if QT_CONFIG(ssl)
void QAbstractHttpServer::sslSetup(const QSslCertificate &certificate,
const QSslKey &privateKey,
diff --git a/src/httpserver/qhttpserver.cpp b/src/httpserver/qhttpserver.cpp
index b971235..061476f 100644
--- a/src/httpserver/qhttpserver.cpp
+++ b/src/httpserver/qhttpserver.cpp
@@ -46,6 +46,7 @@ Q_LOGGING_CATEGORY(lcHS, "qt.httpserver");
/*!
\class QHttpServer
+ \inmodule QtHttpServer
\brief QHttpServer is a simplified API for QAbstractHttpServer and QHttpServerRouter.
\code
@@ -60,6 +61,9 @@ Q_LOGGING_CATEGORY(lcHS, "qt.httpserver");
\endcode
*/
+/*!
+ Creates an instance of QHttpServer with parent \a parent.
+*/
QHttpServer::QHttpServer(QObject *parent)
: QAbstractHttpServer(*new QHttpServerPrivate, parent)
{
@@ -70,16 +74,21 @@ QHttpServer::QHttpServer(QObject *parent)
});
}
-/*! \fn template<typename Rule = QHttpServerRouterRule, typename ... Args> bool route(Args && ... args)
+/*! \fn template<typename Rule = QHttpServerRouterRule, typename ... Args> bool QHttpServer::route(Args && ... args)
+
This function is just a wrapper to simplify the router API.
- This function takes variadic arguments. The last argument is \c a callback (ViewHandler).
- The remaining arguments are used to create a new \a Rule (the default is QHttpServerRouterRule).
- This is in turn added to the QHttpServerRouter.
+ This function takes variadic arguments \a args. The last argument is a
+ callback (\c{ViewHandler}). The remaining arguments are used to create a
+ new \c Rule (the default is QHttpServerRouterRule). This is in turn added
+ to the QHttpServerRouter. It returns \c true if a new rule is created,
+ otherwise it returns \c false.
- \c ViewHandler can only be a lambda. The lambda definition can take two optional special
- arguments: \c {const QHttpServerRequest&} and \c {QHttpServerResponder&&}.
- These special arguments must be the last in the parameter list.
+ \c ViewHandler can only be a lambda. The lambda definition can take two
+ optional special arguments: \c {const QHttpServerRequest&} and
+ \c {QHttpServerResponder&&}. These special arguments must be the last in
+ the parameter list, but in any order, and there can be none, one, or both
+ of them present.
Examples:
@@ -102,11 +111,13 @@ QHttpServer::QHttpServer(QObject *parent)
\sa QHttpServerRouter::addRule
*/
-/*! \fn template<typename ViewHandler> void afterRequest(ViewHandler &&viewHandler)
+/*! \fn template<typename ViewHandler> void QHttpServer::afterRequest(ViewHandler &&viewHandler)
Register a function to be run after each request.
- \c ViewHandler can only be a lambda. The lambda definition can take two
- arguments: \c {QHttpServerResponse &&} and \c {const QHttpServerRequest&} (optional).
+ The \a viewHandler argument can only be a lambda. The lambda definition
+ can take one or two optional arguments: \c {QHttpServerResponse &&} and
+ \c {const QHttpServerRequest &}. If both are given, they can be in either
+ order.
Examples:
@@ -152,6 +163,9 @@ QHttpServerRouter *QHttpServer::router()
return &d->router;
}
+/*!
+ \internal
+*/
void QHttpServer::afterRequestImpl(AfterRequestHandler &&afterRequestHandler)
{
Q_D(QHttpServer);
diff --git a/src/httpserver/qhttpserverfutureresponse.cpp b/src/httpserver/qhttpserverfutureresponse.cpp
index 1d94df4..57c9f2c 100644
--- a/src/httpserver/qhttpserverfutureresponse.cpp
+++ b/src/httpserver/qhttpserverfutureresponse.cpp
@@ -43,6 +43,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QHttpServerFutureResponse
+ \inmodule QtHttpServer
\brief QHttpServerFutureResponse is a simplified API for asynchronous responses.
\code
@@ -61,6 +62,9 @@ QT_BEGIN_NAMESPACE
\endcode
*/
+/*!
+ \internal
+*/
struct QResponseWatcher : public QFutureWatcher<QHttpServerResponse>
{
Q_OBJECT
@@ -74,6 +78,9 @@ public:
QHttpServerResponder responder;
};
+/*!
+ \internal
+*/
class QHttpServerFutureResponsePrivate : public QHttpServerResponsePrivate
{
public:
@@ -87,7 +94,7 @@ public:
};
/*!
- Constructs a new QHttpServerFutureResponse with the \a future response.
+ Constructs a new QHttpServerFutureResponse with the \a futureResp response.
*/
QHttpServerFutureResponse::QHttpServerFutureResponse(const QFuture<QHttpServerResponse> &futureResp)
: QHttpServerFutureResponse(new QHttpServerFutureResponsePrivate{futureResp})
diff --git a/src/httpserver/qhttpserverrequest.cpp b/src/httpserver/qhttpserverrequest.cpp
index 4263c50..2e6ef62 100644
--- a/src/httpserver/qhttpserverrequest.cpp
+++ b/src/httpserver/qhttpserverrequest.cpp
@@ -56,6 +56,9 @@ Q_HTTPSERVER_EXPORT QDebug operator<<(QDebug debug, const QHttpServerRequest &re
#endif
+/*!
+ \internal
+*/
bool QHttpServerRequestPrivate::parseRequestLine(QByteArrayView line)
{
// Request-Line = Method SP Request-URI SP HTTP-Version CRLF
@@ -113,6 +116,9 @@ bool QHttpServerRequestPrivate::parseRequestLine(QByteArrayView line)
return true;
}
+/*!
+ \internal
+*/
qsizetype QHttpServerRequestPrivate::readRequestLine(QAbstractSocket *socket)
{
if (fragment.isEmpty()) {
@@ -159,6 +165,9 @@ qsizetype QHttpServerRequestPrivate::readRequestLine(QAbstractSocket *socket)
return bytes;
}
+/*!
+ \internal
+*/
qint64 QHttpServerRequestPrivate::contentLength() const
{
bool ok = false;
@@ -169,6 +178,9 @@ qint64 QHttpServerRequestPrivate::contentLength() const
return -1; // the header field is not set
}
+/*!
+ \internal
+*/
QByteArray QHttpServerRequestPrivate::headerField(const QByteArray &name,
const QByteArray &defaultValue) const
{
@@ -179,11 +191,17 @@ QByteArray QHttpServerRequestPrivate::headerField(const QByteArray &name,
return allValues.join(", ");
}
+/*!
+ \internal
+*/
QList<QByteArray> QHttpServerRequestPrivate::headerFieldValues(const QByteArray &name) const
{
return parser.headerFieldValues(name);
}
+/*!
+ \internal
+*/
qsizetype QHttpServerRequestPrivate::readHeader(QAbstractSocket *socket)
{
if (fragment.isEmpty()) {
@@ -265,12 +283,18 @@ qsizetype QHttpServerRequestPrivate::readHeader(QAbstractSocket *socket)
return bytes;
}
+/*!
+ \internal
+*/
QHttpServerRequestPrivate::QHttpServerRequestPrivate(const QHostAddress &remoteAddress)
: remoteAddress(remoteAddress)
{
clear();
}
+/*!
+ \internal
+*/
bool QHttpServerRequestPrivate::parse(QAbstractSocket *socket)
{
qsizetype read;
@@ -307,6 +331,9 @@ bool QHttpServerRequestPrivate::parse(QAbstractSocket *socket)
return read != -1;
}
+/*!
+ \internal
+*/
void QHttpServerRequestPrivate::clear()
{
parser.clear();
@@ -325,6 +352,9 @@ void QHttpServerRequestPrivate::clear()
// The body reading functions were mostly copied from QHttpNetworkReplyPrivate
+/*!
+ \internal
+*/
// note this function can only be used for non-chunked, non-compressed with
// known content length
qsizetype QHttpServerRequestPrivate::readBodyFast(QAbstractSocket *socket)
@@ -353,6 +383,9 @@ qsizetype QHttpServerRequestPrivate::readBodyFast(QAbstractSocket *socket)
return haveRead;
}
+/*!
+ \internal
+*/
qsizetype QHttpServerRequestPrivate::readRequestBodyRaw(QAbstractSocket *socket, qsizetype size)
{
// FIXME get rid of this function and just use readBodyFast and give it socket->bytesAvailable()
@@ -381,6 +414,9 @@ qsizetype QHttpServerRequestPrivate::readRequestBodyRaw(QAbstractSocket *socket,
return bytes;
}
+/*!
+ \internal
+*/
qsizetype QHttpServerRequestPrivate::readRequestBodyChunked(QAbstractSocket *socket)
{
qsizetype bytes = 0;
@@ -440,6 +476,9 @@ qsizetype QHttpServerRequestPrivate::readRequestBodyChunked(QAbstractSocket *soc
return bytes;
}
+/*!
+ \internal
+*/
qsizetype QHttpServerRequestPrivate::getChunkSize(QAbstractSocket *socket, qsizetype *chunkSize)
{
qsizetype bytes = 0;
@@ -479,33 +518,62 @@ qsizetype QHttpServerRequestPrivate::getChunkSize(QAbstractSocket *socket, qsize
return bytes;
}
+/*!
+ \class QHttpServerRequest
+ \inmodule QtHttpServer
+ \brief Encapsulates an HTTP request.
+
+ API for accessing the different parameters of an incoming request.
+*/
+
+/*!
+ \internal
+*/
QHttpServerRequest::QHttpServerRequest(const QHostAddress &remoteAddress) :
d(new QHttpServerRequestPrivate(remoteAddress))
{}
+/*!
+ Destroys a QHttpServerRequest
+*/
QHttpServerRequest::~QHttpServerRequest()
{}
+/*!
+ Returns the combined value of all headers with the named \a key.
+*/
QByteArray QHttpServerRequest::value(const QByteArray &key) const
{
return d->parser.combinedHeaderValue(key);
}
+/*!
+ Returns the URL the request asked for.
+*/
QUrl QHttpServerRequest::url() const
{
return d->url;
}
+/*!
+ Returns the query in the request.
+*/
QUrlQuery QHttpServerRequest::query() const
{
return QUrlQuery(d->url.query());
}
+/*!
+ Returns the method of the request.
+*/
QHttpServerRequest::Method QHttpServerRequest::method() const
{
return d->method;
}
+/*!
+ Returns all the request headers.
+*/
QVariantMap QHttpServerRequest::headers() const
{
QVariantMap ret;
@@ -514,11 +582,17 @@ QVariantMap QHttpServerRequest::headers() const
return ret;
}
+/*!
+ Returns the body of the request.
+*/
QByteArray QHttpServerRequest::body() const
{
return d->body;
}
+/*!
+ Returns the address of the origin host of the request.
+*/
QHostAddress QHttpServerRequest::remoteAddress() const
{
return d->remoteAddress;
diff --git a/src/httpserver/qhttpserverresponder.cpp b/src/httpserver/qhttpserverresponder.cpp
index 94fdad9..0db17dd 100644
--- a/src/httpserver/qhttpserverresponder.cpp
+++ b/src/httpserver/qhttpserverresponder.cpp
@@ -41,6 +41,20 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QHttpServerResponder
+ \inmodule QtHttpServer
+ \brief API for sending replies from an HTTP server.
+
+ Provides functions for writing back to an HTTP client with overloads for
+ serializing JSON objects. It also has support for writing HTTP headers and
+ status code. This class can be constructed by calling the \c protected
+ \c static function \c makeResponder() in the QAbstractHttpServer class.
+*/
+
+/*!
+ \internal
+*/
static const QLoggingCategory &lc()
{
static const QLoggingCategory category("qt.httpserver.response");
@@ -92,6 +106,9 @@ static const std::map<QHttpServerResponder::StatusCode, QByteArray> statusString
#undef XX
};
+/*!
+ \internal
+*/
template <qint64 BUFFERSIZE = 512>
struct IOChunkedTransfer
{
@@ -174,8 +191,7 @@ struct IOChunkedTransfer
};
/*!
- Constructs a QHttpServerResponder using the request \a request
- and the socket \a socket.
+ \internal
*/
QHttpServerResponder::QHttpServerResponder(const QHttpServerRequest &request,
QTcpSocket *socket) :
diff --git a/src/httpserver/qhttpserverresponse.cpp b/src/httpserver/qhttpserverresponse.cpp
index 0d4ba4b..b325d71 100644
--- a/src/httpserver/qhttpserverresponse.cpp
+++ b/src/httpserver/qhttpserverresponse.cpp
@@ -41,21 +41,46 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QHttpServerResponse
+ \inmodule QtHttpServer
+ \brief Encapsulates an HTTP response.
+
+ API for creating, reading and modifying a response from an HTTP server,
+ and for writing its contents to a QHttpServerResponder.
+ It has numerous constructors, and \c static function \c fromFile for
+ constructing it from the contents of a file. There are functions for
+ setting, getting, and removing headers, and for getting the data, status
+ code and mime type.
+*/
+
+/*!
+ \internal
+*/
QHttpServerResponsePrivate::QHttpServerResponsePrivate(
QByteArray &&d, const QHttpServerResponse::StatusCode sc)
: data(std::move(d)),
statusCode(sc)
{ }
+/*!
+ \internal
+*/
QHttpServerResponsePrivate::QHttpServerResponsePrivate(const QHttpServerResponse::StatusCode sc)
: statusCode(sc)
{ }
+/*!
+ Move-constructs an instance of a QHttpServerResponse object from \a other.
+*/
QHttpServerResponse::QHttpServerResponse(QHttpServerResponse &&other) noexcept
: d_ptr(std::move(other.d_ptr))
{
}
+/*!
+ Move-assigns the values of \a other to this object.
+*/
QHttpServerResponse& QHttpServerResponse::operator=(QHttpServerResponse &&other) noexcept
{
if (this == &other)
@@ -65,6 +90,9 @@ QHttpServerResponse& QHttpServerResponse::operator=(QHttpServerResponse &&other)
return *this;
}
+/*!
+ Creates a QHttpServerResponse object with the status code \a statusCode.
+*/
QHttpServerResponse::QHttpServerResponse(
const QHttpServerResponse::StatusCode statusCode)
: QHttpServerResponse(QHttpServerLiterals::contentTypeXEmpty(),
@@ -73,21 +101,34 @@ QHttpServerResponse::QHttpServerResponse(
{
}
+/*!
+ Creates a QHttpServerResponse object from \a data.
+*/
QHttpServerResponse::QHttpServerResponse(const char *data)
: QHttpServerResponse(QByteArray::fromRawData(data, qstrlen(data)))
{
}
+/*!
+ Creates a QHttpServerResponse object from \a data.
+*/
QHttpServerResponse::QHttpServerResponse(const QString &data)
: QHttpServerResponse(data.toUtf8())
{
}
+/*!
+ Creates a QHttpServerResponse object from \a data.
+*/
QHttpServerResponse::QHttpServerResponse(const QByteArray &data)
: QHttpServerResponse(QMimeDatabase().mimeTypeForData(data).name().toLocal8Bit(), data)
{
}
+/*!
+ Move-constructs a QHttpServerResponse whose body will contain the given
+ \a data.
+*/
QHttpServerResponse::QHttpServerResponse(QByteArray &&data)
: QHttpServerResponse(
QMimeDatabase().mimeTypeForData(data).name().toLocal8Bit(),
@@ -95,18 +136,44 @@ QHttpServerResponse::QHttpServerResponse(QByteArray &&data)
{
}
+/*!
+ Creates a QHttpServerResponse object from \a data.
+*/
QHttpServerResponse::QHttpServerResponse(const QJsonObject &data)
: QHttpServerResponse(QHttpServerLiterals::contentTypeJson(),
QJsonDocument(data).toJson(QJsonDocument::Compact))
{
}
+/*!
+ Creates a QHttpServerResponse object from \a data.
+*/
QHttpServerResponse::QHttpServerResponse(const QJsonArray &data)
: QHttpServerResponse(QHttpServerLiterals::contentTypeJson(),
QJsonDocument(data).toJson(QJsonDocument::Compact))
{
}
+/*!
+ \fn QHttpServerResponse::QHttpServerResponse(const QByteArray &mimeType,
+ const QByteArray &data,
+ const StatusCode status)
+ \fn QHttpServerResponse::QHttpServerResponse(QByteArray &&mimeType,
+ const QByteArray &data,
+ const StatusCode status)
+ \fn QHttpServerResponse::QHttpServerResponse(const QByteArray &mimeType,
+ QByteArray &&data,
+ const StatusCode status)
+ \fn QHttpServerResponse::QHttpServerResponse(QByteArray &&mimeType,
+ QByteArray &&data,
+ const StatusCode status)
+
+ Creates a QHttpServer response.
+
+ The response will use the given \a status code and deliver the \a data as
+ its body, with a \c ContentType header describing it as being of MIME type
+ \a mimeType.
+*/
QHttpServerResponse::QHttpServerResponse(const QByteArray &mimeType,
const QByteArray &data,
const StatusCode status)
@@ -139,10 +206,19 @@ QHttpServerResponse::QHttpServerResponse(QByteArray &&mimeType,
setHeader(QHttpServerLiterals::contentTypeHeader(), std::move(mimeType));
}
+/*!
+ Destroys a QHttpServerResponse object.
+*/
QHttpServerResponse::~QHttpServerResponse()
{
}
+/*!
+ Returns a QHttpServerResponse from the content of the file \a fileName.
+
+ It is the caller's responsibility to sanity-check the filename, and to have
+ a well-defined policy for which files the server will request.
+*/
QHttpServerResponse QHttpServerResponse::fromFile(const QString &fileName)
{
QFile file(fileName);
@@ -154,6 +230,9 @@ QHttpServerResponse QHttpServerResponse::fromFile(const QString &fileName)
return QHttpServerResponse(mimeType, data);
}
+/*!
+ \internal
+*/
QHttpServerResponse::QHttpServerResponse(QHttpServerResponsePrivate *d)
: d_ptr(d)
{
@@ -161,7 +240,7 @@ QHttpServerResponse::QHttpServerResponse(QHttpServerResponsePrivate *d)
}
/*!
- Returns response body.
+ Returns the response body.
*/
QByteArray QHttpServerResponse::data() const
{
@@ -169,6 +248,9 @@ QByteArray QHttpServerResponse::data() const
return d->data;
}
+/*!
+ Returns the status code.
+*/
QHttpServerResponse::StatusCode QHttpServerResponse::statusCode() const
{
Q_D(const QHttpServerResponse);
@@ -176,7 +258,7 @@ QHttpServerResponse::StatusCode QHttpServerResponse::statusCode() const
}
/*!
- Returns HTTP "Content-Type" header.
+ Returns the value of the HTTP "Content-Type" header.
\note Default value is "text/html"
*/
@@ -231,6 +313,10 @@ void QHttpServerResponse::addHeader(const QByteArray &name, const QByteArray &va
d->headers.emplace(name, value);
}
+/*!
+ Adds the HTTP headers in \a headers,
+ does not override any previously set headers.
+*/
void QHttpServerResponse::addHeaders(QHttpServerResponder::HeaderList headers)
{
for (auto &&header : headers)
@@ -305,7 +391,7 @@ void QHttpServerResponse::setHeaders(QHttpServerResponder::HeaderList headers)
}
/*!
- Returns true if the response contains an HTTP header with name \a name,
+ Returns true if the response contains an HTTP header with name \a header,
otherwise returns false.
*/
bool QHttpServerResponse::hasHeader(const QByteArray &header) const
@@ -332,7 +418,7 @@ bool QHttpServerResponse::hasHeader(const QByteArray &name,
}
/*!
- Returns values of the HTTP header with name \a name
+ Returns values of the HTTP header with name \a name.
*/
QVector<QByteArray> QHttpServerResponse::headers(const QByteArray &name) const
{
diff --git a/src/httpserver/qhttpserverrouter.cpp b/src/httpserver/qhttpserverrouter.cpp
index e28d5cf..202f0ff 100644
--- a/src/httpserver/qhttpserverrouter.cpp
+++ b/src/httpserver/qhttpserverrouter.cpp
@@ -42,6 +42,9 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcRouter, "qt.httpserver.router")
+/*!
+ \internal
+*/
static const QMap<int, QLatin1String> defaultConverters = {
{ QMetaType::Int, QLatin1String("[+-]?\\d+") },
{ QMetaType::Long, QLatin1String("[+-]?\\d+") },
@@ -67,6 +70,7 @@ static const QMap<int, QLatin1String> defaultConverters = {
/*!
\class QHttpServerRouter
\brief Provides functions to bind a URL to a \c ViewHandler.
+ \inmodule QtHttpServer
You can register \c ViewHandler as a callback for requests to a specific URL.
Variable parts in the route can be specified by the arguments in ViewHandler.
@@ -99,7 +103,8 @@ static const QMap<int, QLatin1String> defaultConverters = {
/*! \fn template <typename Type> bool QHttpServerRouter::addConverter(const QLatin1String &regexp)
- Adds a new converter for type \e Type matching regular expression \a regexp.
+ Adds a new converter for type \e Type matching regular expression \a regexp,
+ and returns \c true if this was successful, otherwise returns \c false.
Automatically try to register an implicit converter from QString to \e Type.
If there is already a converter of type \e Type, that converter's regexp
@@ -137,7 +142,7 @@ static const QMap<int, QLatin1String> defaultConverters = {
/*! \fn template <typename ViewHandler, typename ViewTraits = QHttpServerRouterViewTraits<ViewHandler>> bool QHttpServerRouter::addRule(QHttpServerRouterRule *rule)
- Adds a new \a rule.
+ Adds a new \a rule and returns \c true if this was successful.
Inside addRule, we determine ViewHandler arguments and generate a list of
their QMetaType::Type ids. Then we parse the URL and replace each \c <arg>
@@ -161,13 +166,14 @@ static const QMap<int, QLatin1String> defaultConverters = {
\note This function takes over ownership of \a rule.
*/
-/*! \fn template<typename ViewHandler, typename ViewTraits = QHttpServerRouterViewTraits<ViewHandler>> auto bindCaptured(ViewHandler &&handler, QRegularExpressionMatch &match) const -> typename ViewTraits::BindableType
+/*! \fn template<typename ViewHandler, typename ViewTraits = QHttpServerRouterViewTraits<ViewHandler>> typename ViewTraits::BindableType QHttpServerRouter::bindCaptured(ViewHandler &&handler, const QRegularExpressionMatch &match) const
Supplies the \a handler with arguments derived from a URL.
Returns the bound function that accepts whatever remaining arguments the handler may take,
supplying them to the handler after the URL-derived values.
- Each match of the regex applied to the URL (as a string) is converted to the type
- of the handler's parameter at its position, so that passing it works.
+ Each match of the regex applied to the URL (as a string) is converted to
+ the type of the handler's parameter at its position, so that it can be
+ passed as \a match.
\code
QHttpServerRouter router;
@@ -291,7 +297,7 @@ bool QHttpServerRouter::addRuleImpl(QHttpServerRouterRule *rule,
}
/*!
- Handles each new request for the HTTP server.
+ Handles each new \a request for the HTTP server using \a socket.
Iterates through the list of rules to find the first that matches,
then executes this rule, returning \c true. Returns \c false if no rule
diff --git a/src/httpserver/qhttpserverrouterrule.cpp b/src/httpserver/qhttpserverrouterrule.cpp
index a3c5fd9..634846b 100644
--- a/src/httpserver/qhttpserverrouterrule.cpp
+++ b/src/httpserver/qhttpserverrouterrule.cpp
@@ -44,6 +44,9 @@ Q_LOGGING_CATEGORY(lcRouterRule, "qt.httpserver.router.rule")
static const auto methodEnum = QMetaEnum::fromType<QHttpServerRequest::Method>();
+/*!
+ \internal
+*/
static QHttpServerRequest::Methods strToMethods(const char *strMethods)
{
QHttpServerRequest::Methods methods;
@@ -61,6 +64,7 @@ static QHttpServerRequest::Methods strToMethods(const char *strMethods)
/*!
\class QHttpServerRouterRule
\brief The QHttpServerRouterRule is the base class for QHttpServerRouter rules.
+ \inmodule QtHttpServer
Use QHttpServerRouterRule to specify expected request parameters:
@@ -115,7 +119,7 @@ static QHttpServerRequest::Methods strToMethods(const char *strMethods)
The rule accepts all HTTP methods by default.
- \sq QHttpServerRequest::Method
+ \sa QHttpServerRequest::Methods
*/
QHttpServerRouterRule::QHttpServerRouterRule(const QString &pathPattern,
RouterHandler &&routerHandler)
@@ -131,7 +135,7 @@ QHttpServerRouterRule::QHttpServerRouterRule(const QString &pathPattern,
The rule accepts any combinations of available HTTP methods.
- \sa QHttpServerRequest::Method
+ \sa QHttpServerRequest::Methods
*/
QHttpServerRouterRule::QHttpServerRouterRule(const QString &pathPattern,
const QHttpServerRequest::Methods methods,
@@ -149,8 +153,6 @@ QHttpServerRouterRule::QHttpServerRouterRule(const QString &pathPattern,
\note \a methods shall be joined with | as separator (not spaces or commas)
and that either the upper-case or the capitalised form may be used.
-
- \sa QMetaEnum::keysToValue
*/
QHttpServerRouterRule::QHttpServerRouterRule(const QString &pathPattern,
const char *methods,
@@ -177,7 +179,7 @@ QHttpServerRouterRule::~QHttpServerRouterRule()
}
/*!
- Returns true if the methods is valid
+ Returns \c true if the methods is valid
*/
bool QHttpServerRouterRule::hasValidMethods() const
{
@@ -186,7 +188,12 @@ bool QHttpServerRouterRule::hasValidMethods() const
}
/*!
- This function is called by QHttpServerRouter when a new request is received.
+ Executes this rule for the given \a request, if it matches.
+
+ This function is called by QHttpServerRouter when it receives a new
+ request. If the given \a request matches this rule, this function handles
+ the request by delivering a response to the given \a socket, then returns
+ \c true. Otherwise, it returns \c false.
*/
bool QHttpServerRouterRule::exec(const QHttpServerRequest &request,
QTcpSocket *socket) const
@@ -202,7 +209,12 @@ bool QHttpServerRouterRule::exec(const QHttpServerRequest &request,
}
/*!
- This virtual function is called by exec() to check if request matches the rule.
+ Determines whether a given \a request matches this rule.
+
+ This virtual function is called by exec() to check if \a request matches
+ this rule. If a match is found, it is stored in the object pointed to by
+ \a match (which \e{must not} be \nullptr) and this function returns
+ \c true. Otherwise, it returns \c false.
*/
bool QHttpServerRouterRule::matches(const QHttpServerRequest &request,
QRegularExpressionMatch *match) const
diff --git a/src/sslserver/qsslserver.cpp b/src/sslserver/qsslserver.cpp
index 45c4826..12f0c68 100644
--- a/src/sslserver/qsslserver.cpp
+++ b/src/sslserver/qsslserver.cpp
@@ -35,11 +35,30 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcSS, "qt.sslserver");
+/*!
+ \class QSslServer
+ \inmodule QtHttpServer
+ \brief Subclass of QTcpServer to accept secure connections.
+
+ API for running a server with Transport Layer Security. Calling \c bind
+ on a QAbstractHttpServer with an instance of QSslServer turns it into an
+ HTTPS server.
+*/
+
+/*!
+ Creates a QSslServer object with \a parent as the parent object.
+*/
QSslServer::QSslServer(QObject *parent):
QTcpServer (parent), d(new QSslServerPrivate)
{
}
+/*!
+ Creates a QSslServer object.
+
+ Its parent object shall be \a parent and it shall use \a sslConfiguration as its
+ TLS configuration.
+*/
QSslServer::QSslServer(const QSslConfiguration &sslConfiguration,
QObject *parent):
QTcpServer (parent), d(new QSslServerPrivate)
@@ -47,8 +66,14 @@ QSslServer::QSslServer(const QSslConfiguration &sslConfiguration,
d->sslConfiguration = sslConfiguration;
}
+/*!
+ Destroys a QsslServer object.
+*/
QSslServer::~QSslServer() = default;
+/*!
+ Handle incoming connection with socket handle \a handle.
+*/
void QSslServer::incomingConnection(qintptr handle)
{
QSslSocket *socket = new QSslSocket(this);
@@ -70,6 +95,9 @@ void QSslServer::incomingConnection(qintptr handle)
addPendingConnection(socket);
}
+/*!
+ Sets the SSL configuration to \a sslConfiguration.
+*/
void QSslServer::setSslConfiguration(const QSslConfiguration &sslConfiguration)
{
d->sslConfiguration = sslConfiguration;