QHttpServerResponse Class

Encapsulates an HTTP response. More...

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

Public Types

Public Functions

QHttpServerResponse(const int &mimeType, const int &data, QHttpServerResponse::StatusCode status)
QHttpServerResponse(const int &mimeType, int &&data, QHttpServerResponse::StatusCode status)
QHttpServerResponse(class QHttpServerResponse &&other)
(since 6.8) Q_DECL_IMPORT setHeaders(const class QHttpHeaders &newHeaders)
QHttpServerResponse &operator=(class QHttpServerResponse &&other)

Detailed Description

API for creating, reading and modifying a response from an HTTP server, and for writing its contents to a QHttpServerResponder. It has numerous constructors, and static function fromFile for constructing it from the contents of a file. There are functions for setting, getting, and removing headers, and for getting the data, status code and mime type.

Member Type Documentation

[alias] QHttpServerResponse::StatusCode

Type alias for QHttpServerResponder::StatusCode

Member Function Documentation

[default] QHttpServerResponse::QHttpServerResponse(const int &mimeType, const int &data, QHttpServerResponse::StatusCode status)

[default] QHttpServerResponse::QHttpServerResponse(const int &mimeType, int &&data, QHttpServerResponse::StatusCode status)

Creates a QHttpServer response.

The response will use the given status code and deliver the data as its body, with a ContentType header describing it as being of MIME type mimeType.

[noexcept default] QHttpServerResponse::QHttpServerResponse(class QHttpServerResponse &&other)

Move-constructs a new QHttpServerResponse from other.

[since 6.8] Q_DECL_IMPORT QHttpServerResponse::setHeaders(const class QHttpHeaders &newHeaders)

This is an overloaded function.

This function was introduced in Qt 6.8.

[noexcept default] QHttpServerResponse &QHttpServerResponse::operator=(class QHttpServerResponse &&other)

Move-assigns other to this QHttpServerResponse instance.