QHttp2Configuration Class
QHttp2Configuration 类用于控制 HTTP/2 的参数和设置。更多内容...
| 标题: | #include <QHttp2Configuration> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
- 所有成员的列表,包括继承的成员
- QHttp2Configuration 属于“网络编程 API”和“隐式共享类”的一部分。
注意:该类中的所有函数均为可重入函数。
公共函数
| QHttp2Configuration() | |
| QHttp2Configuration(const QHttp2Configuration &other) | |
| QHttp2Configuration(QHttp2Configuration &&other) | |
| ~QHttp2Configuration() | |
| bool | huffmanCompressionEnabled() const |
(since 6.9) unsigned int | maxConcurrentStreams() const |
| unsigned int | maxFrameSize() const |
| bool | serverPushEnabled() const |
| unsigned int | sessionReceiveWindowSize() const |
| void | setHuffmanCompressionEnabled(bool enable) |
(since 6.9) void | setMaxConcurrentStreams(unsigned int value) |
| bool | setMaxFrameSize(unsigned int size) |
| void | setServerPushEnabled(bool enable) |
| bool | setSessionReceiveWindowSize(unsigned int size) |
| bool | setStreamReceiveWindowSize(unsigned int size) |
| unsigned int | streamReceiveWindowSize() const |
| void | swap(QHttp2Configuration &other) |
| QHttp2Configuration & | operator=(QHttp2Configuration &&other) |
| QHttp2Configuration & | operator=(const QHttp2Configuration &other) |
相关的非成员
| bool | operator!=(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs) |
| bool | operator==(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs) |
详细说明
QHttp2Configuration 控制 HTTP/2 协议启用时,QNetworkAccessManager 将用于发送请求和处理响应的 HTTP/2 参数和设置。
QHttp2Configuration 目前支持的 HTTP/2 参数包括:
- 用于连接级流量控制的会话窗口大小。将在需要时作为标识符为 0 的流中的 'WINDOW_UPDATE' 帧发送给远程对等方。
- 用于流级流量控制的流接收窗口大小。作为“SETTINGS_INITIAL_WINDOW_SIZE”参数在初始 SETTINGS 帧中发送;必要时,QNetworkAccessManager 会在其打开的流上发送“WINDOW_UPDATE”帧。
- 最大帧大小。该参数限制了来自远程对等方的帧所能承载的最大有效载荷。由QNetworkAccessManager 作为“SETTINGS_MAX_FRAME_SIZE”参数发送在初始“SETTINGS”帧中。
- 服务器推送。用于启用或禁用服务器推送。作为“SETTINGS_ENABLE_PUSH”参数发送在初始的“SETTINGS”帧中。
QHttp2Configuration 类还控制头压缩算法(HPACK)是否额外使用霍夫曼编码进行字符串压缩。
注意: 必须在向指定主机发送第一个请求(即建立 HTTP/2 会话)之前完成配置设置。
另请参阅 QNetworkRequest::setHttp2Configuration()、QNetworkRequest::http2Configuration() 以及QNetworkAccessManager 。
成员函数文档
QHttp2Configuration::QHttp2Configuration()
默认情况下会构建一个 QHttp2Configuration 对象。
此类配置具有以下值:
- 服务器推送已禁用
- 已启用霍夫曼字符串压缩
- 连接级流量控制的窗口大小为 65535 个八位字节
- 流级流量控制的窗口大小为 65535 字节
- 帧大小为 16384 字节
- 最大可接受的报头列表大小为 262144 字节(256 KiB)
QHttp2Configuration::QHttp2Configuration(const QHttp2Configuration &other)
复制并创建此 QHttp2Configuration 实例。
[noexcept] QHttp2Configuration::QHttp2Configuration(QHttp2Configuration &&other)
将此 QHttp2Configuration 从other
[noexcept] QHttp2Configuration::~QHttp2Configuration()
析构函数。
bool QHttp2Configuration::huffmanCompressionEnabled() const
如果 HPACK 中启用了霍夫曼编码,则返回true 。
另请参阅 setHuffmanCompressionEnabled 。
[since 6.9] unsigned int QHttp2Configuration::maxConcurrentStreams() const
返回最大并发流数。
该函数在 Qt 6.9 中引入。
另请参阅 setMaxConcurrentStreams()。
unsigned int QHttp2Configuration::maxFrameSize() const
返回 HTTP/2 帧的最大有效载荷大小。默认(初始)值为 16384 字节。
另请参阅 setMaxFrameSize()。
bool QHttp2Configuration::serverPushEnabled() const
如果已启用服务器推送,则返回 true。
注意:默认情况下, QNetworkAccessManager 会通过 'SETTINGS' 框架禁用服务器推送。
另请参阅 setServerPushEnabled 。
unsigned int QHttp2Configuration::sessionReceiveWindowSize() const
返回用于连接级流量控制的窗口大小。QNetworkAccessManager 将使用的默认值为2147483647个字节。
另请参阅 setSessionReceiveWindowSize()。
void QHttp2Configuration::setHuffmanCompressionEnabled(bool enable)
如果enable 的值为true ,HPACK 压缩将额外使用霍夫曼编码对字符串进行压缩。默认启用。
注意:此 参数仅影响QNetworkAccessManager 发送的“HEADERS”帧。
另请参阅 huffmanCompressionEnabled 。
[since 6.9] void QHttp2Configuration::setMaxConcurrentStreams(unsigned int value)
将value 设置为在发送SETTINGS帧时向对等方声明的最大并发流数。
该函数在 Qt 6.9 中引入。
另请参阅 maxConcurrentStreams()。
bool QHttp2Configuration::setMaxFrameSize(unsigned int size)
设置QNetworkAccessManager 在发送初始SETTINGS帧时向服务器通告的最大帧大小。
注意:虽然 此size 必须在16384到16777215(含)之间,但实际携带有效载荷的帧中,有效载荷大小可能小于16384。
成功时返回true ,否则返回false 。
另请参阅 maxFrameSize()。
void QHttp2Configuration::setServerPushEnabled(bool enable)
如果enable 的值是true ,则远程服务器可能会利用服务器推送功能提前发送响应。
另请参阅 serverPushEnabled 。
bool QHttp2Configuration::setSessionReceiveWindowSize(unsigned int size)
设置连接级流量控制的窗口大小。size 不能为 0,且不得超过 2147483647 个字节。
成功时返回 `true `,否则返回 `false `。
另请参阅 sessionReceiveWindowSize 。
bool QHttp2Configuration::setStreamReceiveWindowSize(unsigned int size)
设置流级流量控制的窗口大小。size 不能为 0,且不得超过 2147483647 个字节。
成功时返回true ,否则返回false 。
另请参阅 streamReceiveWindowSize 。
unsigned int QHttp2Configuration::streamReceiveWindowSize() const
返回用于流级流量控制的窗口大小。QNetworkAccessManager 将使用的默认值为214748364个字节(参见RFC 7540)。
另请参阅 setStreamReceiveWindowSize()。
[noexcept] void QHttp2Configuration::swap(QHttp2Configuration &other)
将此配置与other 互换。此操作非常快速,且绝不会失败。
[noexcept] QHttp2Configuration &QHttp2Configuration::operator=(QHttp2Configuration &&other)
将other 移动并赋值给QHttp2Configuration 。
QHttp2Configuration &QHttp2Configuration::operator=(const QHttp2Configuration &other)
将other 通过复制赋值给此QHttp2Configuration 。
相关非会员
[noexcept] bool operator!=(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs)
如果lhs 和rhs 的 HTTP/2 参数集不一致,则返回true 。
[noexcept] bool operator==(const QHttp2Configuration &lhs, const QHttp2Configuration &rhs)
如果lhs 和rhs 具有相同的 HTTP/2 参数集,则返回 `true `。
© 2026 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.