QHttpServerConfiguration Class
The QHttpServerConfiguration class controls server parameters. More...
Header: | #include <QHttpServerConfiguration> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS HttpServer) target_link_libraries(mytarget PRIVATE Qt6::HttpServer) |
qmake: | QT += httpserver |
Since: | Qt 6.9 |
Public Functions
QHttpServerConfiguration() | |
QHttpServerConfiguration(const QHttpServerConfiguration &other) | |
QHttpServerConfiguration(QHttpServerConfiguration &&other) | |
~QHttpServerConfiguration() | |
QList<std::pair<QHostAddress, int>> | blacklist() const |
quint32 | rateLimitPerSecond() const |
void | setBlacklist(const QList<std::pair<QHostAddress, int>> &subnetList) |
void | setRateLimitPerSecond(quint32 maxRequests) |
void | setWhitelist(const QList<std::pair<QHostAddress, int>> &subnetList) |
void | swap(QHttpServerConfiguration &other) |
QList<std::pair<QHostAddress, int>> | whitelist() const |
QHttpServerConfiguration & | operator=(const QHttpServerConfiguration &other) |
Related Non-Members
bool | operator!=(const QHttpServerConfiguration &lhs, const QHttpServerConfiguration &rhs) |
bool | operator==(const QHttpServerConfiguration &lhs, const QHttpServerConfiguration &rhs) |
Member Function Documentation
QHttpServerConfiguration::QHttpServerConfiguration()
Default constructs a QHttpServerConfiguration object.
Such a configuration has the following values:
- Rate limit is disabled
QHttpServerConfiguration::QHttpServerConfiguration(const QHttpServerConfiguration &other)
Copy-constructs this QHttpServerConfiguration.
[noexcept]
QHttpServerConfiguration::QHttpServerConfiguration(QHttpServerConfiguration &&other)
Move-constructs this QHttpServerConfiguration from other
[noexcept]
QHttpServerConfiguration::~QHttpServerConfiguration()
Destructor.
QList<std::pair<QHostAddress, int>> QHttpServerConfiguration::blacklist() const
Returns the blacklist of subnets that are denied access by QHttpServer.
See also setBlacklist().
quint32 QHttpServerConfiguration::rateLimitPerSecond() const
Returns maximum number of incoming requests per second per IP accepted by the server.
See also setRateLimitPerSecond().
void QHttpServerConfiguration::setBlacklist(const QList<std::pair<QHostAddress, int>> &subnetList)
Sets subnetList as the blacklist of subnets.
IP addresses in this list will be denied access by QHttpServer. The blacklist is active only when the whitelist is empty.
See also blacklist(), setWhitelist(), and QHostAddress::parseSubnet().
void QHttpServerConfiguration::setRateLimitPerSecond(quint32 maxRequests)
Sets maxRequests as the maximum number of incoming requests per second per IP that will be accepted by QHttpServer. If the limit is exceeded, QHttpServer will respond with QHttpServerResponder::StatusCode::TooManyRequests.
See also rateLimitPerSecond() and QHttpServerResponder::StatusCode.
void QHttpServerConfiguration::setWhitelist(const QList<std::pair<QHostAddress, int>> &subnetList)
Sets subnetList as the whitelist of allowed subnets.
When the list is not empty, only IP addresses in this list will be allowed by QHttpServer. The whitelist takes priority over the blacklist.
Each subnet is represented as a pair consisting of:
- A base IP address of type QHostAddress.
- A CIDR prefix length of type int, which defines the subnet mask.
To allow only a specific IP address, use a prefix length of 32 for IPv4 (e.g., "192.168.1.100/32") or 128 for IPv6 (e.g., "2001:db8::1/128").
See also whitelist(), setBlacklist(), and QHostAddress::parseSubnet().
[noexcept]
void QHttpServerConfiguration::swap(QHttpServerConfiguration &other)
Swaps this configuration with other. This operation is very fast and never fails.
QList<std::pair<QHostAddress, int>> QHttpServerConfiguration::whitelist() const
Returns the whitelist of subnets allowed by QHttpServer.
See also setWhitelist().
QHttpServerConfiguration &QHttpServerConfiguration::operator=(const QHttpServerConfiguration &other)
Copy-assigns other to this QHttpServerConfiguration.
Related Non-Members
[noexcept]
bool operator!=(const QHttpServerConfiguration &lhs, const QHttpServerConfiguration &rhs)
Returns true
if lhs and rhs do not have the same set of configuration parameters.
[noexcept]
bool operator==(const QHttpServerConfiguration &lhs, const QHttpServerConfiguration &rhs)
Returns true
if lhs and rhs have the same set of configuration parameters.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.