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) |
(since 6.11) int | setMaximumBodySize(int maxSize) |
(since 6.11) int | setMaximumHeaderFieldCount(int maxSize) |
(since 6.11) int | setMaximumHeaderFieldSize(int maxSize) |
(since 6.11) int | setMaximumTotalHeaderSize(int maxSize) |
(since 6.11) int | setMaximumUrlSize(int maxSize) |
| 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().
[since 6.11] int QHttpServerConfiguration::setMaximumBodySize(int maxSize)
Sets maxSize as the maximum size of the body that the server will accept. If the limit is exceeded, QHttpServer will respond with status 413 Content Too Large. If maxSize is -1 there is no limit. The default is 32 MiB.
This function was introduced in Qt 6.11.
See also maximumBodySize() and QHttpServerResponder::StatusCode.
[since 6.11] int QHttpServerConfiguration::setMaximumHeaderFieldCount(int maxSize)
Sets maxSize as the maximum number of header fields that the server will accept. If the limit is exceeded, QHttpServer will respond with status 431 Request Header Fields Too Large. If maxSize is -1 there is no limit. The default is 128.
This function was introduced in Qt 6.11.
See also maximumHeaderFieldCount() and QHttpServerResponder::StatusCode.
[since 6.11] int QHttpServerConfiguration::setMaximumHeaderFieldSize(int maxSize)
Sets maxSize as the maximum size of a single header that the server will accept. If the limit is exceeded, QHttpServer will respond with status 431 Request Header Fields Too Large. If maxSize is -1 there is no limit. The default is 48 KiB.
This function was introduced in Qt 6.11.
See also maximumHeaderFieldSize() and QHttpServerResponder::StatusCode.
[since 6.11] int QHttpServerConfiguration::setMaximumTotalHeaderSize(int maxSize)
Sets maxSize as the maximum total size of the headers that the server will accept. If the limit is exceeded, QHttpServer will respond with status 431 Request Header Fields Too Large. If maxSize is -1 there is no limit. The default is 64 KiB.
This function was introduced in Qt 6.11.
See also maximumTotalHeaderSize() and QHttpServerResponder::StatusCode.
[since 6.11] int QHttpServerConfiguration::setMaximumUrlSize(int maxSize)
Sets maxSize as the maximum size of the URL that the server will accept. If the limit is exceeded, QHttpServer will respond with status 414 Request-URI Too Long. If maxSize is -1 there is no limit. The default is 64 KiB.
This function was introduced in Qt 6.11.
See also maximumUrlSize() and QHttpServerResponder::StatusCode.
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.