QHttpServerWebSocketUpgradeResponse Class | Qt HTTP Server | Qt 6.12.0
Description: Response to return when verifying WebSocket upgrades on HTTP server.
Keywords: class

- Qt 6.12
- Qt HTTP Server
- C++ Classes
- QHttpServerWebSocketUpgradeResponse
- Qt 6.12.0 Reference Documentation

# QHttpServerWebSocketUpgradeResponse Class

Response to return when verifying WebSocket upgrades on HTTP server. More...

Header: | `#include <QHttpServerWebSocketUpgradeResponse>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS HttpServer)` `target_link_libraries(mytarget PRIVATE Qt6::HttpServer)`
qmake: | `QT += httpserver`
Since: | Qt 6.8

- List of all members, including inherited members

## Public Types

enum class | ResponseType { Accept, Deny, PassToNext }

## Public Functions

| 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)

## Static Public Members

QHttpServerWebSocketUpgradeResponse | accept()
QHttpServerWebSocketUpgradeResponse | deny()
QHttpServerWebSocketUpgradeResponse | deny(int status, QByteArray message)
QHttpServerWebSocketUpgradeResponse | passToNext()

## Detailed Description

Use this class to return when determining whether a socket upgrade should succeed. If type() is Accept upgrade the socket, if type() is Deny send an error with the given denyStatus() and denyMessage(), and if type() is PassToNext proceed to the next registered handler. If all handlers return PassToNext or none exist, QAbstractHttpServer::missingHandler() is executed.

See also QAbstractHttpServer::addWebSocketUpgradeVerifier() and QAbstractHttpServer::missingHandler().

## Member Type Documentation

### enum class QHttpServerWebSocketUpgradeResponse::ResponseType

Response types

Constant | Value | Description
--- | --- | ---
`QHttpServerWebSocketUpgradeResponse::ResponseType::Accept` | `0` | Accept the WebSocket upgrade request.
`QHttpServerWebSocketUpgradeResponse::ResponseType::Deny` | `1` | Deny the WebSocket upgrade request.
`QHttpServerWebSocketUpgradeResponse::ResponseType::PassToNext` | `2` | Pass the Websocket upgrade decision to the next verifier if any.

See also QAbstractHttpServer::addWebSocketUpgradeVerifier() and type().

## Member Function Documentation

### QHttpServerWebSocketUpgradeResponse::QHttpServerWebSocketUpgradeResponse(const QHttpServerWebSocketUpgradeResponse &other)

Copy-constructs an instance of a QHttpServerWebSocketUpgradeResponse object from other.

### `[noexcept]` QHttpServerWebSocketUpgradeResponse::~QHttpServerWebSocketUpgradeResponse()

Destroys a QHttpServerWebSocketUpgradeResponse object.

### `[static]` QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::accept()

Creates an instance of QHttpServerWebSocketUpgradeResponse with type() Accept.

See also ResponseType and type().

### `[static]` QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::deny()

Creates an instance of QHttpServerWebSocketUpgradeResponse with type() Deny, denyStatus() `403` and the denyMessage() `"Forbidden"`.

See also ResponseType, type(), denyStatus(), and denyMessage().

### `[static]` QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::deny(int status, QByteArray message)

Creates an instance of QHttpServerWebSocketUpgradeResponse with type() Deny, denyStatus() status and denyMessage() message.

See also ResponseType, type(), denyStatus(), and denyMessage().

### QByteArray QHttpServerWebSocketUpgradeResponse::denyMessage() &&

Returns the error message to return if type() is Deny.

### const QByteArray &QHttpServerWebSocketUpgradeResponse::denyMessage() const &

Returns the error message to return if type() is Deny.

### int QHttpServerWebSocketUpgradeResponse::denyStatus() const

Returns the HTTP status code to return if type() is Deny.

### `[static]` QHttpServerWebSocketUpgradeResponse QHttpServerWebSocketUpgradeResponse::passToNext()

Creates an instance of QHttpServerWebSocketUpgradeResponse with type() PassToNext.

See also ResponseType and type().

### `[noexcept]` void QHttpServerWebSocketUpgradeResponse::swap(QHttpServerWebSocketUpgradeResponse &other)

Swaps the contents of this with other

### QHttpServerWebSocketUpgradeResponse::ResponseType QHttpServerWebSocketUpgradeResponse::type() const

Returns the type of response.

See also ResponseType.

### `[noexcept]` QHttpServerWebSocketUpgradeResponse &QHttpServerWebSocketUpgradeResponse::operator=(QHttpServerWebSocketUpgradeResponse &&other)

Move-assigns the values of other to this object.

### QHttpServerWebSocketUpgradeResponse &QHttpServerWebSocketUpgradeResponse::operator=(const QHttpServerWebSocketUpgradeResponse &other)

Copy-assigns the values of other to this object.