QHttpServerConfiguration Class

The QHttpServerConfiguration class controls server parameters. 更多...

頭: #include <QHttpServerConfiguration>
CMake: find_package(Qt6 REQUIRED COMPONENTS HttpServer)
target_link_libraries(mytarget PRIVATE Qt6::HttpServer)
qmake: QT += httpserver
Since: Qt 6.9

公共函數

QHttpServerConfiguration ()
QHttpServerConfiguration (const QHttpServerConfiguration & other )
QHttpServerConfiguration (QHttpServerConfiguration && other )
~QHttpServerConfiguration ()
(從 6.10 起) QSpan<const std::pair<QHostAddress, int>> blacklist () const
(從 6.10 起) std::chrono::seconds keepAliveTimeout () const
quint32 rateLimitPerSecond () const
(從 6.10 起) void setBlacklist (QSpan<const std::pair<QHostAddress, int>> subnetList )
(從 6.10 起) void setKeepAliveTimeout (std::chrono::seconds timeout )
void setRateLimitPerSecond (quint32 maxRequests )
(從 6.10 起) void setWhitelist (QSpan<const std::pair<QHostAddress, int>> subnetList )
void swap (QHttpServerConfiguration & other )
(從 6.10 起) QSpan<const std::pair<QHostAddress, int>> whitelist () const
QHttpServerConfiguration & operator= (QHttpServerConfiguration && other )
QHttpServerConfiguration & operator= (const QHttpServerConfiguration & other )
bool operator!= (const QHttpServerConfiguration & lhs , const QHttpServerConfiguration & rhs )
bool operator== (const QHttpServerConfiguration & lhs , const QHttpServerConfiguration & rhs )

詳細描述

成員函數文檔編製

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 ()

析構函數。

[since 6.10] QSpan <const std::pair < QHostAddress , int >> QHttpServerConfiguration:: blacklist () const

Returns the blacklist of subnets that are denied access by QHttpServer .

該函數在 Qt 6.10 引入。

另請參閱 setBlacklist ().

[since 6.10] std::chrono::seconds QHttpServerConfiguration:: keepAliveTimeout () const

Returns the keep-alive timeout used by QHttpServer .

該函數在 Qt 6.10 引入。

另請參閱 setKeepAliveTimeout ().

quint32 QHttpServerConfiguration:: rateLimitPerSecond () const

Returns maximum number of incoming requests per second per IP accepted by the server.

另請參閱 setRateLimitPerSecond ().

[since 6.10] void QHttpServerConfiguration:: setBlacklist ( QSpan <const std::pair < QHostAddress , int >> subnetList )

設置 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.

該函數在 Qt 6.10 引入。

另請參閱 blacklist (), setWhitelist (),和 QHostAddress::parseSubnet ().

[since 6.10] void QHttpServerConfiguration:: setKeepAliveTimeout ( std::chrono::seconds timeout )

設置 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.

該函數在 Qt 6.10 引入。

另請參閱 keepAliveTimeout ().

void QHttpServerConfiguration:: setRateLimitPerSecond ( quint32 maxRequests )

設置 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 .

另請參閱 rateLimitPerSecond () 和 QHttpServerResponder::StatusCode .

[since 6.10] void QHttpServerConfiguration:: setWhitelist ( QSpan <const std::pair < QHostAddress , int >> subnetList )

設置 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" ).

該函數在 Qt 6.10 引入。

另請參閱 whitelist (), setBlacklist (),和 QHostAddress::parseSubnet ().

[noexcept] void QHttpServerConfiguration:: swap ( QHttpServerConfiguration & other )

Swaps this configuration with other 。此操作很快且從不失敗。

[since 6.10] QSpan <const std::pair < QHostAddress , int >> QHttpServerConfiguration:: whitelist () const

Returns the whitelist of subnets allowed by QHttpServer .

該函數在 Qt 6.10 引入。

另請參閱 setWhitelist ().

[noexcept] QHttpServerConfiguration &QHttpServerConfiguration:: operator= ( QHttpServerConfiguration && other )

移動賦值 other 到此 QHttpServerConfiguration .

QHttpServerConfiguration &QHttpServerConfiguration:: operator= (const QHttpServerConfiguration & other )

Copy-assigns other 到此 QHttpServerConfiguration .

相關非成員

[noexcept] bool operator!= (const QHttpServerConfiguration & lhs , const QHttpServerConfiguration & rhs )

返迴 true if lhs and rhs do not have the same set of configuration parameters.

[noexcept] bool operator== (const QHttpServerConfiguration & lhs , const QHttpServerConfiguration & rhs )

返迴 true if lhs and rhs have the same set of configuration parameters.