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 参数和设置,当启用 HTTP/2 协议时,QNetworkAccessManager 将使用这些参数和设置发送请求和处理响应。
QHttp2Configuration 当前支持的 HTTP/2 参数包括
- 用于连接级流量控制的会话窗口大小。将在需要时作为流上的 "WINDOW_UPDATE "帧发送给远程对等设备,标识符为 0。
- 用于流级流量控制的流接收窗口大小。在初始 SETTINGS 帧中作为 "SETTINGS_INITIAL_WINDOW_SIZE "参数发送,需要时将在QNetworkAccessManager 打开的流上发送 "WINDOW_UPDATE "帧。
- 最大帧大小。该参数限制了来自远程对等设备的帧的最大有效载荷。由QNetworkAccessManager 发送,作为初始 "SETTINGS "帧中的 "SETTINGS_MAX_FRAME_SIZE "参数。
- 服务器推送。允许启用或禁用服务器推送。作为初始 "SETTINGS "帧中的 "SETTINGS_ENABLE_PUSH "参数发送。
QHttp2Configuration 类还能控制报头压缩算法(HPACK)是否额外使用哈夫曼编码进行字符串压缩。
注: 必须在向指定主机发送第一个请求(从而建立 HTTP/2 会话)之前设置配置。
另请参阅 QNetworkRequest::setHttp2Configuration()、QNetworkRequest::http2Configuration() 和QNetworkAccessManager 。
成员函数文档
QHttp2Configuration::QHttp2Configuration()
Default 构造一个 QHttp2Configuration 对象。
这种配置具有以下值:
- 服务器推送已禁用
- 启用哈夫曼字符串压缩
- 连接级流量控制的窗口大小为 65535 个八进制字节
- 流级流量控制的窗口大小为 65535 八位字节
- 帧大小为 16384 八位字节
QHttp2Configuration::QHttp2Configuration(const QHttp2Configuration &other)
复制-构建此 QHttp2Configuration。
[noexcept]
QHttp2Configuration::QHttp2Configuration(QHttp2Configuration &&other)
Move-construct this QHttp2Configuration fromother
[noexcept]
QHttp2Configuration::~QHttp2Configuration()
毁灭者
bool QHttp2Configuration::huffmanCompressionEnabled() const
如果 HPACK 中的 Huffman 编码已启用,则返回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)之间的范围内,但携带有效载荷的帧的实际有效载荷大小可能小于 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
。
© 2025 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.