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 (const QHttpServerResponse::StatusCode statusCode ) | |
QHttpServerResponse (const char * data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (const QString & data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (const QByteArray & data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (QByteArray && data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (const QJsonObject & data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (const QJsonArray & data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (const QByteArray & mimeType , const QByteArray & data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (QByteArray && mimeType , const QByteArray & data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (const QByteArray & mimeType , QByteArray && data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (QByteArray && mimeType , QByteArray && data , const QHttpServerResponse::StatusCode status = StatusCode::Ok) | |
QHttpServerResponse (QHttpServerResponse && other ) | |
~QHttpServerResponse () | |
void | addHeader (QByteArray && name , QByteArray && value ) |
void | addHeader (QByteArray && name , const QByteArray & value ) |
void | addHeader (const QByteArray & name , QByteArray && value ) |
void | addHeader (const QByteArray & name , const QByteArray & value ) |
void | addHeaders (QHttpServerResponder::HeaderList headers ) |
void | addHeaders (const Container & headerList ) |
void | clearHeader (const QByteArray & name ) |
void | clearHeaders () |
QByteArray | data () const |
bool | hasHeader (const QByteArray & header ) const |
bool | hasHeader (const QByteArray & name , const QByteArray & value ) const |
QList<QByteArray> | headers (const QByteArray & name ) const |
QByteArray | mimeType () const |
void | setHeader (QByteArray && name , QByteArray && value ) |
void | setHeader (QByteArray && name , const QByteArray & value ) |
void | setHeader (const QByteArray & name , QByteArray && value ) |
void | setHeader (const QByteArray & name , const QByteArray & value ) |
void | setHeaders (QHttpServerResponder::HeaderList headers ) |
QHttpServerResponse::StatusCode | statusCode () const |
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 .
Creates a QHttpServerResponse object from data with the status code status .
Creates a QHttpServerResponse object from data with the status code status .
[explicit]
QHttpServerResponse::
QHttpServerResponse
(const
QByteArray
&
data
, const
QHttpServerResponse::StatusCode
status
= StatusCode::Ok)
Creates a QHttpServerResponse object from data with the status code status .
[explicit]
QHttpServerResponse::
QHttpServerResponse
(
QByteArray
&&
data
, const
QHttpServerResponse::StatusCode
status
= StatusCode::Ok)
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 .
[noexcept]
QHttpServerResponse::
QHttpServerResponse
(
QHttpServerResponse
&&
other
)
Move-constructs an instance of a QHttpServerResponse object from other .
[noexcept]
QHttpServerResponse::
~QHttpServerResponse
()
销毁 QHttpServerResponse 对象。
Adds the HTTP header with name name and value value , does not override any previously set headers.
Adds the HTTP header with name name and value value , does not override any previously set headers.
Adds the HTTP header with name name and value value , does not override any previously set headers.
Adds the HTTP header with name name and value value , does not override any previously set headers.
Adds the HTTP headers in headers , does not override any previously set headers.
Adds the HTTP headers in headerList , does not override any previously set headers.
容器
must be a container that represents the header name and content as key-value pairs.
Removes the HTTP header with name name .
Removes all HTTP headers.
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.
Returns true if the response contains an HTTP header with name header ,否则返回 false。
Returns true if the response contains an HTTP header with name name and with value value ,否则返回 false。
Returns values of the HTTP header with name name .
另请参阅 setHeaders ().
Returns the value of the HTTP "Content-Type" header.
注意: Default value is "text/html"
Sets the HTTP header with name name and value value , overriding any previously set headers.
另请参阅 hasHeader ().
Sets the HTTP header with name name and value value , overriding any previously set headers.
Sets the HTTP header with name name and value value , overriding any previously set headers.
Sets the HTTP header with name name and value value , overriding any previously set headers.
Sets the headers headers , overriding any previously set headers.
另请参阅 headers ().
Returns the status code.
[noexcept]
QHttpServerResponse
&QHttpServerResponse::
operator=
(
QHttpServerResponse
&&
other
)
Move-assigns the values of other 到此对象。