Encapsulates an HTTP response. 更多...
| 头: |
#include <QHttpServerResponse>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS HttpServer)
target_link_libraries(mytarget PRIVATE Qt6::HttpServer)
|
| qmake: |
QT += httpserver
|
| Since: | Qt 6.4 |
| StatusCode |
| QHttpServerResponse (QHttpServerResponse::StatusCode statusCode ) | |
| QHttpServerResponse (QByteArray && data , QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
| QHttpServerResponse (const QByteArray & data , QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
| QHttpServerResponse (const QJsonArray & data , QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
| QHttpServerResponse (const QJsonObject & data , QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
| QHttpServerResponse (const QString & data , QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
| QHttpServerResponse (const char * data , QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
| QHttpServerResponse (const QByteArray & mimeType , QByteArray && data , QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
| QHttpServerResponse (const QByteArray & mimeType , const QByteArray & data , QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
| QHttpServerResponse (QHttpServerResponse && other ) | |
| ~QHttpServerResponse () | |
| QByteArray | data () const |
(从 6.8 起)
QHttpHeaders
|
headers () const |
| QByteArray | mimeType () const |
(从 6.8 起)
void
|
setHeaders (QHttpHeaders && newHeaders ) |
(从 6.8 起)
void
|
setHeaders (const QHttpHeaders & newHeaders ) |
| QHttpServerResponse::StatusCode | statusCode () const |
| void | swap (QHttpServerResponse & other ) |
| QHttpServerResponse & | operator= (QHttpServerResponse && other ) |
| QHttpServerResponse | fromFile (const QString & fileName ) |
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.
[alias]
QHttpServerResponse::
StatusCode
Type alias for QHttpServerResponder::StatusCode
创建 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
.
Creates a QHttpServerResponse object with the status code statusCode .
Move-constructs a QHttpServerResponse whose body will contain the given data with the status code status .
Creates a QHttpServerResponse object from data with the status code status .
Creates a QHttpServerResponse object from data with the status code status .
Creates a QHttpServerResponse object from data with the status code status .
Creates a QHttpServerResponse object from data with the status code status .
Creates a QHttpServerResponse object from data with the status code status .
[noexcept]
QHttpServerResponse::
QHttpServerResponse
(
QHttpServerResponse
&&
other
)
Move-constructs a new QHttpServerResponse from other .
[noexcept]
QHttpServerResponse::
~QHttpServerResponse
()
销毁 QHttpServerResponse 对象。
Returns the response body.
[static]
QHttpServerResponse
QHttpServerResponse::
fromFile
(const
QString
&
fileName
)
返回 QHttpServerResponse from the content of the file fileName .
It is the caller's responsibility to sanity-check the filename, and to have a well-defined policy for which files the server will request.
[since 6.8]
QHttpHeaders
QHttpServerResponse::
headers
() const
Returns the currently set HTTP headers.
该函数在 Qt 6.8 引入。
另请参阅 setHeaders ().
Returns the value of the HTTP "Content-Type" header.
注意: Default value is "text/html"
[since 6.8]
void
QHttpServerResponse::
setHeaders
(
QHttpHeaders
&&
newHeaders
)
设置 newHeaders as the HTTP headers, overriding any previously set headers.
该函数在 Qt 6.8 引入。
另请参阅 headers ().
[since 6.8]
void
QHttpServerResponse::
setHeaders
(const
QHttpHeaders
&
newHeaders
)
这是重载函数。
该函数在 Qt 6.8 引入。
Returns the status code.
[noexcept]
void
QHttpServerResponse::
swap
(
QHttpServerResponse
&
other
)
交换此 QHttpServerResponse with other 。此操作非常快且从不失败。
[noexcept]
QHttpServerResponse
&QHttpServerResponse::
operator=
(
QHttpServerResponse
&&
other
)
移动赋值 other 到此 QHttpServerResponse 实例。