QHttpServerRequest Class

Encapsulates an HTTP request. More...

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

Public Types

enum class Method { Unknown, Get, Put, Delete, Post, …, AnyKnown }
flags Methods

Public Functions

(since 6.10) QHttpServerRequest()
(since 6.10) QHttpServerRequest(const QHttpServerRequest &other)
(since 6.10) QHttpServerRequest(QHttpServerRequest &&other)
~QHttpServerRequest()
QByteArray body() const
QHttpHeaders headers() &&
const QHttpHeaders &headers() const &
(since 6.5) QHostAddress localAddress() const
(since 6.5) quint16 localPort() const
QHttpServerRequest::Method method() const
QUrlQuery query() const
QHostAddress remoteAddress() const
(since 6.5) quint16 remotePort() const
(since 6.7) QSslConfiguration sslConfiguration() const
(since 6.10) void swap(QHttpServerRequest &other)
QUrl url() const
QByteArray value(const QByteArray &key) const
(since 6.10) QHttpServerRequest &operator=(QHttpServerRequest &&other)
(since 6.10) QHttpServerRequest &operator=(const QHttpServerRequest &other)
QDebug operator<<(QDebug debug, const QHttpServerRequest &request)

Detailed Description

API for accessing the different parameters of an incoming request.

Member Type Documentation

enum class QHttpServerRequest::Method
flags QHttpServerRequest::Methods

This enum type specifies an HTTP request method:

ConstantValueDescription
QHttpServerRequest::Method::Unknown0x0000An unknown method.
QHttpServerRequest::Method::Get0x0001HTTP GET method.
QHttpServerRequest::Method::Put0x0002HTTP PUT method.
QHttpServerRequest::Method::Delete0x0004HTTP DELETE method.
QHttpServerRequest::Method::Post0x0008HTTP POST method.
QHttpServerRequest::Method::Head0x0010HTTP HEAD method.
QHttpServerRequest::Method::Options0x0020HTTP OPTIONS method.
QHttpServerRequest::Method::Patch0x0040HTTP PATCH method (RFC 5789).
QHttpServerRequest::Method::Connect0x0080HTTP CONNECT method.
QHttpServerRequest::Method::Trace0x0100HTTP TRACE method.
QHttpServerRequest::Method::AnyKnownGet | Put | Delete | Post | Head | Options | Patch | Connect | TraceCombination of all known methods.

The Methods type is a typedef for QFlags<Method>. It stores an OR combination of Method values.

Member Function Documentation

QHttpHeaders QHttpServerRequest::headers() &&

const QHttpHeaders &QHttpServerRequest::headers() const &

Returns all the request headers.

[since 6.10] QHttpServerRequest::QHttpServerRequest()

Constructs a QHttpServerRequest.

This function was introduced in Qt 6.10.

[since 6.10] QHttpServerRequest::QHttpServerRequest(const QHttpServerRequest &other)

Copy constructs a QHttpServerRequest using other.

This function was introduced in Qt 6.10.

[noexcept, since 6.10] QHttpServerRequest::QHttpServerRequest(QHttpServerRequest &&other)

Move constructs a QHttpServerRequest using other.

This function was introduced in Qt 6.10.

[noexcept] QHttpServerRequest::~QHttpServerRequest()

Destroys a QHttpServerRequest

QByteArray QHttpServerRequest::body() const

Returns the body of the request.

[since 6.5] QHostAddress QHttpServerRequest::localAddress() const

Returns the host address of the local socket which received the request.

This function was introduced in Qt 6.5.

[since 6.5] quint16 QHttpServerRequest::localPort() const

Returns the port of the local socket which received the request.

This function was introduced in Qt 6.5.

QHttpServerRequest::Method QHttpServerRequest::method() const

Returns the method of the request.

QUrlQuery QHttpServerRequest::query() const

Returns the query in the request.

QHostAddress QHttpServerRequest::remoteAddress() const

Returns the address of the origin host of the request.

[since 6.5] quint16 QHttpServerRequest::remotePort() const

Returns the port of the origin host of the request.

This function was introduced in Qt 6.5.

[since 6.7] QSslConfiguration QHttpServerRequest::sslConfiguration() const

Returns the configuration of the established TLS connection. The configurations will return true for isNull() if the connection is not using TLS.

This function was introduced in Qt 6.7.

[noexcept, since 6.10] void QHttpServerRequest::swap(QHttpServerRequest &other)

Swaps values between this and other.

This function was introduced in Qt 6.10.

QUrl QHttpServerRequest::url() const

Returns the URL the request asked for.

QByteArray QHttpServerRequest::value(const QByteArray &key) const

Returns the combined value of all headers with the named key.

[noexcept, since 6.10] QHttpServerRequest &QHttpServerRequest::operator=(QHttpServerRequest &&other)

Move assigns a QHttpServerRequest using other.

This function was introduced in Qt 6.10.

[since 6.10] QHttpServerRequest &QHttpServerRequest::operator=(const QHttpServerRequest &other)

Assigns a QHttpServerRequest using other.

This function was introduced in Qt 6.10.

Related Non-Members

QDebug operator<<(QDebug debug, const QHttpServerRequest &request)

Writes information about request to the debug stream.

See also QDebug.