QHttpServerRequest Class | Qt HTTP Server (original) (raw)

Encapsulates an HTTP request. More...

Header: #include
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

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:

Constant Value Description
QHttpServerRequest::Method::Unknown 0x0000 An unknown method.
QHttpServerRequest::Method::Get 0x0001 HTTP GET method.
QHttpServerRequest::Method::Put 0x0002 HTTP PUT method.
QHttpServerRequest::Method::Delete 0x0004 HTTP DELETE method.
QHttpServerRequest::Method::Post 0x0008 HTTP POST method.
QHttpServerRequest::Method::Head 0x0010 HTTP HEAD method.
QHttpServerRequest::Method::Options 0x0020 HTTP OPTIONS method.
QHttpServerRequest::Method::Patch 0x0040 HTTP PATCH method (RFC 5789).
QHttpServerRequest::Method::Connect 0x0080 HTTP CONNECT method.
QHttpServerRequest::Method::Trace 0x0100 HTTP TRACE method.
QHttpServerRequest::Method::AnyKnown Get | Put Delete Post Head Options Patch Connect Trace Combination of all known methods.

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

Member Function Documentation

QHttpHeaders QHttpServerRequest::headers() &&

const QHttpHeaders &QHttpServerRequest::headers() const &

Returns all the request headers.

[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.

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.

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

Writes information about request to the debug stream.

See also QDebug.

© 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.