PySide6.QtHttpServer.QHttpServerConfiguration

class QHttpServerConfiguration

The QHttpServerConfiguration class controls server parameters.

Added in version 6.9.

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

__init__()

Default constructs a QHttpServerConfiguration object.

Such a configuration has the following values:

  • Rate limit is disabled.

  • Keep-alive timeout is set to 15 seconds.

  • Whitelist is empty.

  • Blacklist is empty.

  • Maximum Url size is 64 KiB.

  • Maximum total header size is 64 KiB.

  • Maximum header field size is 48 KiB.

  • Maximum number of header fields is 128.

  • Maximum body size is 32 MiB.

__init__(other)
Parameters:

otherQHttpServerConfiguration

Copy-constructs this QHttpServerConfiguration .

keepAliveTimeout()
Return type:

std::chrono::seconds

Returns the keep-alive timeout used by QHttpServer . This is the amount of time an idle connections may remain open before it is timed out.

maximumBodySize()
Return type:

int

Returns the maximum size of the incoming body accepted by the server.

maximumHeaderFieldCount()
Return type:

int

Returns the maximum number of incoming header fields accepted by the server.

maximumHeaderFieldSize()
Return type:

int

Returns the maximum size of each incoming header field accepted by the server.

maximumTotalHeaderSize()
Return type:

int

Returns the maximum size of the total incoming headers accepted by the server.

maximumUrlSize()
Return type:

int

Returns the maximum size of the URL accepted by the server.

__ne__(rhs)
Parameters:

rhsQHttpServerConfiguration

Return type:

bool

__eq__(rhs)
Parameters:

rhsQHttpServerConfiguration

Return type:

bool

rateLimitPerSecond()
Return type:

int

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

This limit is applied separately to each client IP address. Returns 0 if rate limiting is disabled.

setKeepAliveTimeout(timeout)
Parameters:

timeoutstd::chrono::seconds

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.

setMaximumBodySize(maxBodySize)
Parameters:

maxBodySize – int

Sets maxSize as the maximum size of the request 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.

setMaximumHeaderFieldCount(maxNumberOfHeaders)
Parameters:

maxNumberOfHeaders – int

Sets maxSize as the maximum number of header fields that the server will accept in a request. 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.

setMaximumHeaderFieldSize(maxSingleHeaderSize)
Parameters:

maxSingleHeaderSize – int

Sets maxSize as the maximum size of any single header field that the server will accept in a request. 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.

setMaximumTotalHeaderSize(maxTotalHeadersSize)
Parameters:

maxTotalHeadersSize – int

Sets maxSize as the maximum total size of the header fields that the server will accept in a request. 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.

setMaximumUrlSize(maxUrlSize)
Parameters:

maxUrlSize – int

Sets maxSize as the maximum size of the request 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.

setRateLimitPerSecond(maxRequests)
Parameters:

maxRequests – int

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 TooManyRequests .

This limit is applied separately to each client IP address. A value of 0 disables rate limiting.

By default, rate limiting is disabled.

swap(other)
Parameters:

otherQHttpServerConfiguration

Swaps this configuration with other. This operation is very fast and never fails.