QHttpServerWebSocketUpgradeResponse Class
在 HTTP 服务器上验证 WebSocket 升级时返回的响应。更多
头文件: | #include <QHttpServerWebSocketUpgradeResponse> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS HttpServer) target_link_libraries(mytarget PRIVATE Qt6::HttpServer) |
qmake: | QT += httpserver |
自 | Qt 6.8 |
公共类型
enum class | ResponseType { Accept, Deny, PassToNext } |
公共函数
QHttpServerWebSocketUpgradeResponse(const QHttpServerWebSocketUpgradeResponse &other) | |
~QHttpServerWebSocketUpgradeResponse() | |
QByteArray | denyMessage() && |
const QByteArray & | denyMessage() const & |
int | denyStatus() const |
void | swap(QHttpServerWebSocketUpgradeResponse &other) |
QHttpServerWebSocketUpgradeResponse::ResponseType | type() const |
QHttpServerWebSocketUpgradeResponse & | operator=(QHttpServerWebSocketUpgradeResponse &&other) |
QHttpServerWebSocketUpgradeResponse & | operator=(const QHttpServerWebSocketUpgradeResponse &other) |
静态公共成员
QHttpServerWebSocketUpgradeResponse | accept() |
QHttpServerWebSocketUpgradeResponse | deny() |
QHttpServerWebSocketUpgradeResponse | deny(int status, QByteArray message) |
QHttpServerWebSocketUpgradeResponse | passToNext() |
详细说明
在确定套接字升级是否成功时使用该类返回值。如果type() 返回Accept ,则升级套接字;如果type() 返回Deny ,则使用给定的denyStatus() 和denyMessage() 发送错误信息;如果type() 返回PassToNext ,则转到下一个已注册的处理程序。如果所有处理程序都返回PassToNext 或都不存在,则执行QAbstractHttpServer::missingHandler()。
另请参阅 QAbstractHttpServer::addWebSocketUpgradeVerifier() 和QAbstractHttpServer::missingHandler()。
成员类型文档
enum class QHttpServerWebSocketUpgradeResponse::ResponseType
响应类型
常数 | 值 | 说明 |
---|---|---|
QHttpServerWebSocketUpgradeResponse::ResponseType::Accept | 0 | 接受 WebSocket 升级请求。 |
QHttpServerWebSocketUpgradeResponse::ResponseType::Deny | 1 | 拒绝 WebSocket 升级请求。 |
QHttpServerWebSocketUpgradeResponse::ResponseType::PassToNext | 2 | 将 WebSocket 升级决定传递给下一个验证程序(如果有)。 |
另请参阅 QAbstractHttpServer::addWebSocketUpgradeVerifier() 和type()。
成员函数文档
QHttpServerWebSocketUpgradeResponse::QHttpServerWebSocketUpgradeResponse(const QHttpServerWebSocketUpgradeResponse &other)
从other 复制-构建 QHttpServerWebSocketUpgradeResponse 对象的实例。
[noexcept]
QHttpServerWebSocketUpgradeResponse::~QHttpServerWebSocketUpgradeResponse()
销毁QHttpServerWebSocketUpgradeResponse 对象。
[static]
QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::accept()
通过type()Accept 创建QHttpServerWebSocketUpgradeResponse 的实例。
另请参阅 ResponseType 和type() 。
[static]
QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::deny()
通过type()Deny,denyStatus()403
和denyMessage()"Forbidden"
创建QHttpServerWebSocketUpgradeResponse 的实例。
另请参阅 ResponseType,type(),denyStatus() 和denyMessage()。
[static]
QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::deny(int status, QByteArray message)
通过type()Deny,denyStatus()status 和denyMessage()message 创建QHttpServerWebSocketUpgradeResponse 的实例。
另请参阅 ResponseType,type(),denyStatus() 和denyMessage()。
QByteArray QHttpServerWebSocketUpgradeResponse::denyMessage() &&
const QByteArray &QHttpServerWebSocketUpgradeResponse::denyMessage() const &
int QHttpServerWebSocketUpgradeResponse::denyStatus() const
如果type() 是Deny ,则返回 HTTP 状态代码。
[static]
QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::passToNext()
通过type()PassToNext 创建QHttpServerWebSocketUpgradeResponse 的实例。
另请参阅 ResponseType 和type() 。
[noexcept]
void QHttpServerWebSocketUpgradeResponse::swap(QHttpServerWebSocketUpgradeResponse &other)
的内容与other
QHttpServerWebSocketUpgradeResponse::ResponseType QHttpServerWebSocketUpgradeResponse::type() const
返回响应类型。
另请参阅 ResponseType 。
[noexcept]
QHttpServerWebSocketUpgradeResponse &QHttpServerWebSocketUpgradeResponse::operator=(QHttpServerWebSocketUpgradeResponse &&other)
移动--将other 的值赋给该对象。
QHttpServerWebSocketUpgradeResponse &QHttpServerWebSocketUpgradeResponse::operator=(const QHttpServerWebSocketUpgradeResponse &other)
复制--将other 的值分配给此对象。
© 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.