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()` 方法创建 `QHttpServerWebSocketUpgradeResponse ` 的实例Accept 。
另请参阅 ResponseType 和type()。
[static] QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::deny()
创建一个QHttpServerWebSocketUpgradeResponse 实例,其属性包括type()Deny 、denyStatus()403 以及denyMessage()"Forbidden" 。
另请参阅 ResponseType 、type()、denyStatus() 以及denyMessage()。
[static] QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::deny(int status, QByteArray message)
创建一个QHttpServerWebSocketUpgradeResponse 实例,其中包含type()Deny 、denyStatus()status 以及denyMessage()message 。
另请参阅 ResponseType 、type()、denyStatus() 以及denyMessage()。
QByteArray QHttpServerWebSocketUpgradeResponse::denyMessage() &&
当type()的返回值为Deny 时,返回应返回的错误消息。
const QByteArray &QHttpServerWebSocketUpgradeResponse::denyMessage() const &
当type()的返回值为Deny 时,返回应返回的错误消息。
int QHttpServerWebSocketUpgradeResponse::denyStatus() const
当type()的值为Deny 时,返回应返回的HTTP状态码。
[static] QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::passToNext()
使用 `type()` 方法创建 `QHttpServerWebSocketUpgradeResponse ` 的实例,详见PassToNext 。
另请参阅 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 的值复制并赋值给此对象。
© 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.