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 &&other) | |
(since 6.10) int | setBlacklist(int subnetList) |
(since 6.10) int | setKeepAliveTimeout(std::chrono::seconds timeout) |
| int | setRateLimitPerSecond(int maxRequests) |
(since 6.10) int | setWhitelist(int subnetList) |
| class QHttpServerConfiguration & | operator=(QHttpServerConfiguration &&other) |
Detailed Description
Member Function Documentation
[constexpr noexcept] QHttpServerConfiguration::QHttpServerConfiguration(QHttpServerConfiguration &&other)
Move-constructs this QHttpServerConfiguration from other
[since 6.10] int QHttpServerConfiguration::setBlacklist(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.
This function was introduced in Qt 6.10.
See also blacklist(), setWhitelist(), and QHostAddress::parseSubnet().
[since 6.10] int QHttpServerConfiguration::setKeepAliveTimeout(std::chrono::seconds timeout)
Sets timeout as keep-alive timeout for QHttpServer.
The keep-alive timeout determines how long an idle connection is kept open before being closed. By default, the timeout is set to 15 seconds.
This function was introduced in Qt 6.10.
See also keepAliveTimeout().
int QHttpServerConfiguration::setRateLimitPerSecond(int 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.
[since 6.10] int QHttpServerConfiguration::setWhitelist(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").
This function was introduced in Qt 6.10.
See also whitelist(), setBlacklist(), and QHostAddress::parseSubnet().
[noexcept default] class QHttpServerConfiguration &QHttpServerConfiguration::operator=(QHttpServerConfiguration &&other)
Move-assigns other to this QHttpServerConfiguration.