QHttpServerResponder 类
发送 HTTP 服务器响应的 API。 更多...
头文件 | #include <QHttpServerResponder> |
CMake | find_package(Qt6 REQUIRED COMPONENTS HttpServer) target_link_libraries(mytarget PRIVATE Qt6::HttpServer) |
qmake | QT += httpserver |
自 | Qt 6.4 |
状态 | 技术预览 |
公共类型
HeaderList | |
enum class | StatusCode { Continue, SwitchingProtocols, Processing, Ok, Created, …, NetworkConnectTimeoutError } |
公共函数
QHttpServerResponder(QHttpServerResponder &&other) | |
~QHttpServerResponder() | |
(自 6.5) void | sendResponse(const QHttpServerResponse &response) |
void | write(QIODevice *data, QHttpServerResponder::HeaderList headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
void | write(QIODevice *data, const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
void | write(const QJsonDocument &document, QHttpServerResponder::HeaderList headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
void | write(const QJsonDocument &document, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
void | write(const QByteArray &data, QHttpServerResponder::HeaderList headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
void | write(const QByteArray &data, const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
void | write(QHttpServerResponder::HeaderList headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
void | write(QHttpServerResponder::StatusCode status = StatusCode::Ok) |
void | writeBody(const char *body, qint64 size) |
void | writeBody(const char *body) |
void | writeBody(const QByteArray &body) |
void | writeHeader(const QByteArray &header, const QByteArray &value) |
void | writeHeaders(QHttpServerResponder::HeaderList headers) |
void | writeStatusLine(QHttpServerResponder::StatusCode status = StatusCode::Ok) |
成员类型文档
[别名]
QHttpServerResponder::HeaderList
用于 std::initializer_list< std::pair
enum class QHttpServerResponder::StatusCode
HTTP 状态码
常量 | 值 |
---|---|
QHttpServerResponder::StatusCode::Continue | 100 |
QHttpServerResponder::StatusCode::SwitchingProtocols | 101 |
QHttpServerResponder::StatusCode::Processing | 102 |
QHttpServerResponder::StatusCode::Ok | 200 |
QHttpServerResponder::StatusCode::Created | 201 |
QHttpServerResponder::StatusCode::Accepted | 202 |
QHttpServerResponder::StatusCode::NonAuthoritativeInformation | 203 |
QHttpServerResponder::StatusCode::NoContent | 204 |
QHttpServerResponder::StatusCode::ResetContent | 205 |
QHttpServerResponder::StatusCode::PartialContent | 206 |
QHttpServerResponder::StatusCode::MultiStatus | 207 |
QHttpServerResponder::StatusCode::AlreadyReported | 208 |
QHttpServerResponder::StatusCode::IMUsed | 226 |
QHttpServerResponder::StatusCode::MultipleChoices | 300 |
QHttpServerResponder::StatusCode::MovedPermanently | 301 |
QHttpServerResponder::StatusCode::Found | 302 |
QHttpServerResponder::StatusCode::SeeOther | 303 |
QHttpServerResponder::StatusCode::NotModified | 304 |
QHttpServerResponder::StatusCode::UseProxy | 305 |
QHttpServerResponder::StatusCode::TemporaryRedirect | 307 |
QHttpServerResponder::StatusCode::PermanentRedirect | 308 |
QHttpServerResponder::StatusCode::BadRequest | 400 |
QHttpServerResponder::StatusCode::Unauthorized | 401 |
QHttpServerResponder::StatusCode::PaymentRequired | 402 |
QHttpServerResponder::StatusCode::Forbidden | 403 |
QHttpServerResponder::StatusCode::NotFound | 404 |
QHttpServerResponder::StatusCode::MethodNotAllowed | 405 |
QHttpServerResponder::StatusCode::NotAcceptable | 406 |
QHttpServerResponder::StatusCode::ProxyAuthenticationRequired | 407 |
QHttpServerResponder::StatusCode::RequestTimeout | 408 |
QHttpServerResponder::StatusCode::Conflict | 409 |
QHttpServerResponder::StatusCode::Gone | 410 |
QHttpServerResponder::StatusCode::LengthRequired | 411 |
QHttpServerResponder::StatusCode::PreconditionFailed | 412 |
QHttpServerResponder::StatusCode::PayloadTooLarge | 413 |
QHttpServerResponder::StatusCode::UriTooLong | 414 |
QHttpServerResponder::StatusCode::UnsupportedMediaType | 415 |
QHttpServerResponder::StatusCode::RequestRangeNotSatisfiable | 416 |
QHttpServerResponder::StatusCode::ExpectationFailed | 417 |
QHttpServerResponder::StatusCode::ImATeapot | 418 |
QHttpServerResponder::StatusCode::MisdirectedRequest | 421 |
QHttpServerResponder::StatusCode::UnprocessableEntity | 422 |
QHttpServerResponder::StatusCode::Locked | 423 |
QHttpServerResponder::StatusCode::FailedDependency | 424 |
QHttpServerResponder::StatusCode::UpgradeRequired | 426 |
QHttpServerResponder::StatusCode::PreconditionRequired | 428 |
QHttpServerResponder::StatusCode::TooManyRequests | 429 |
QHttpServerResponder::StatusCode::RequestHeaderFieldsTooLarge | 431 |
QHttpServerResponder::StatusCode::UnavailableForLegalReasons | 451 |
QHttpServerResponder::StatusCode::InternalServerError | 500 |
QHttpServerResponder::StatusCode::NotImplemented | 501 |
QHttpServerResponder::StatusCode::BadGateway | 502 |
QHttpServerResponder::StatusCode::ServiceUnavailable | 503 |
QHttpServerResponder::StatusCode::GatewayTimeout | 504 |
QHttpServerResponder::StatusCode::HttpVersionNotSupported | 505 |
QHttpServerResponder::StatusCode::VariantAlsoNegotiates | 506 |
QHttpServerResponder::StatusCode::InsufficientStorage | 507 |
QHttpServerResponder::StatusCode::LoopDetected | 508 |
QHttpServerResponder::StatusCode::NotExtended | 510 |
QHttpServerResponder::StatusCode::NetworkAuthenticationRequired | 511 |
QHttpServerResponder::StatusCode::NetworkConnectTimeoutError | 599 |
成员函数文档
QHttpServerResponder::QHttpServerResponder(QHttpServerResponder &&other)
移动构造 QHttpServerResponder 实例,使其指向由 other 指向的对象。
[noexcept]
QHttpServerResponder::~QHttpServerResponder()
销毁一个 QHttpServerResponder。
[since 6.5]
void QHttpServerResponder::sendResponse(const QHttpServerResponse &response)
向客户端发送一个 HTTP response。
此函数自 Qt 6.5 起引入。
void QHttpServerResponder::write(QIODevice *data, QHttpServerResponder::HeaderList headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
响应请求数据,返回HTTP状态码 status 和HTTP头部 headers。I/O设备 data 提供响应体。如果 data 是顺序的,则消息体以块的形式发送:否则,函数假设所有内容都可用,并一次性发送所有内容,但以块读取。
注意:此函数将 data 的所有权交给该函数。
void QHttpServerResponder::write(QIODevice *data, const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok)
响应请求数据,返回HTTP状态码 status 和MIME类型 mimeType。I/O设备 data 提供响应体。如果 data 是顺序的,则消息体以块的形式发送:否则,函数假设所有内容都可用,并一次性发送所有内容,但以块读取。
注意:此函数将 data 的所有权交给该函数。
void QHttpServerResponder::write(const QJsonDocument &document, QHttpServerResponder::HeaderList headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
响应请求数据,返回HTTP状态码 status、JSON文档 document 和HTTP头部 headers。
注意:此函数将HTTP内容类型头部设置为 "application/json"。
void QHttpServerResponder::write(const QJsonDocument &document, QHttpServerResponder::StatusCode status = StatusCode::Ok)
响应请求数据,返回HTTP状态码 status 和JSON文档 document。
注意:此函数将HTTP内容类型头部设置为 "application/json"。
void QHttpServerResponder::write(const QByteArray &data, QHttpServerResponder::HeaderList headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
响应请求数据,返回HTTP状态码 status、HTTP头部 headers 和正文 data。
注意:此函数将HTTP内容长度头部设置为。
void QHttpServerResponder::write(const QByteArray &data, const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok)
响应请求数据,返回HTTP状态码 status、MIME类型 mimeType 和正文 data。
void QHttpServerResponder::write(QHttpServerResponder::HeaderList headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
响应请求数据,返回HTTP状态码 status 和HTTP头部 headers。
void QHttpServerResponder::write(QHttpServerResponder::StatusCode status = StatusCode::Ok)
使用HTTP状态码 status 响应请求。
注意:此函数将HTTP内容类型头设置为 "application/x-empty"。
void QHttpServerResponder::writeBody(const char *body, qint64 size)
此函数将大小为 size 的HTTP正文 body 写入。
void QHttpServerResponder::writeBody(const char *body)
此函数写入HTTP正文 body。
void QHttpServerResponder::writeBody(const QByteArray &body)
此函数写入HTTP正文 body。
void QHttpServerResponder::writeHeader(const QByteArray &header, const QByteArray &value)
此函数使用 value 写入HTTP头部 header。
void QHttpServerResponder::writeHeaders(QHttpServerResponder::HeaderList headers)
此函数写入HTTP头部 headers。
void QHttpServerResponder::writeStatusLine(QHttpServerResponder::StatusCode status = StatusCode::Ok)
此函数写入带有HTTP状态码 status 的HTTP状态行。
© 2024 The Qt Company Ltd。本文档中的贡献属于其各自的版权所有者。本文档是根据自由软件基金会发布的 GNU自由文档许可证第1.3版 的条款提供的。Qt及其相关标志是The Qt Company Ltd在芬兰和/或其他国家和地区的商标。所有其他商标均属于其各自的版权所有者。