QHttpServerResponder Class
HTTPサーバーから応答を送信するためのAPI。詳細...
| ヘッダー: | #include <QHttpServerResponder> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS HttpServer) target_link_libraries(mytarget PRIVATE Qt6::HttpServer) |
| qmake: | QT += httpserver |
| 以下のように: | Qt 6.4 |
パブリック型
| enum class | StatusCode { Continue, SwitchingProtocols, Processing, Ok, Created, …, NetworkConnectTimeoutError } |
パブリック関数
| QHttpServerResponder(QHttpServerResponder &&other) | |
| ~QHttpServerResponder() | |
(since 6.11) bool | isResponseCanceled() const |
(since 6.5) void | sendResponse(const QHttpServerResponse &response) |
(since 6.8) void | swap(QHttpServerResponder &other) |
| void | write(QHttpServerResponder::StatusCode status = StatusCode::Ok) |
| void | write(const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
| void | write(const QJsonDocument &document, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
| void | write(QIODevice *data, const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
| void | write(QIODevice *data, const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
| void | write(const QByteArray &data, const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
| void | write(const QByteArray &data, const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
| void | write(const QJsonDocument &document, const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
(since 6.8) void | writeBeginChunked(const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
(since 6.8) void | writeBeginChunked(const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
(since 6.8) void | writeBeginChunked(const QHttpHeaders &headers, QList<QHttpHeaders::WellKnownHeader> trailers, QHttpServerResponder::StatusCode status = StatusCode::Ok) |
(since 6.8) void | writeChunk(const QByteArray &data) |
(since 6.8) void | writeEndChunked(const QByteArray &data) |
(since 6.8) void | writeEndChunked(const QByteArray &data, const QHttpHeaders &trailers) |
詳細な説明
HTTP クライアントへの書き込みを行う関数を提供し、JSON オブジェクトをシリアル化するためのオーバーロードが用意されています。また、HTTP ヘッダーやステータスコードの書き込みもサポートしています。
メンバー型のドキュメント
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 |
メンバ関数のドキュメント
[noexcept] QHttpServerResponder::QHttpServerResponder(QHttpServerResponder &&other)
QHttpServerResponderのインスタンスをムーブコンストラクタで生成し、other が指していたのと同じオブジェクトを指すようにします。
[noexcept] QHttpServerResponder::~QHttpServerResponder()
QHttpServerResponder を破棄します。
[since 6.11] bool QHttpServerResponder::isResponseCanceled() const
クライアントがレスポンスをキャンセルした場合、true を返します。レスポンスがキャンセルされた際に、ハンドラを早期に終了できるようにするために使用されます。
この関数は Qt 6.11 で導入されました。
[since 6.5] void QHttpServerResponder::sendResponse(const QHttpServerResponse &response)
クライアントに対してHTTPのresponse を送信します。
この関数は Qt 6.5 で導入されました。
[noexcept, since 6.8] void QHttpServerResponder::swap(QHttpServerResponder &other)
QHttpServerResponder other をQHttpServerResponder に置き換えます。この操作は非常に高速で、失敗することはありません。
この関数は Qt 6.8 で導入されました。
void QHttpServerResponder::write(QHttpServerResponder::StatusCode status = StatusCode::Ok)
リクエストに対して、HTTPステータスコードstatus を返します。
注:この関数は、HTTP Content-Typeヘッダーを"application/x-empty" に設定します。
void QHttpServerResponder::write(const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
リクエストに対して、HTTPステータスコードstatus およびHTTPヘッダーheaders を返します。
void QHttpServerResponder::write(const QJsonDocument &document, QHttpServerResponder::StatusCode status = StatusCode::Ok)
リクエストに対して、HTTPステータスコードstatus と、JSONドキュメントdocument を返します。
注:この関数は、HTTP Content-Typeヘッダーを「"application/json" 」に設定します。
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(QIODevice *data, const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
リクエストに対して、HTTPステータスコードstatus およびHTTPヘッダーheaders を返します。I/Oデバイスdata がレスポンスの本文を提供します。data がシーケンシャルである場合、メッセージの本文はチャンク単位で送信されます。そうでない場合、この関数はすべてのコンテンツが利用可能であるとみなして一度に送信しますが、読み取りはチャンク単位で行われます。
注:この関数は 、data の所有権を取得します。
void QHttpServerResponder::write(const QByteArray &data, const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok)
リクエストに対して、HTTPステータスコードstatus 、MIMEタイプmimeType 、および本文data を返します。
void QHttpServerResponder::write(const QByteArray &data, const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
リクエストに対して、HTTPステータスコードstatus 、HTTPヘッダーheaders 、および本文data を返します。
注:この関数は、HTTP Content-Lengthヘッダーを設定します。
void QHttpServerResponder::write(const QJsonDocument &document, const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
リクエストに対して、HTTPステータスコードstatus 、JSONドキュメントdocument 、およびHTTPヘッダーheaders を返します。
注:この関数は、HTTP Content-Typeヘッダーを"application/json" に設定します。
[since 6.8] void QHttpServerResponder::writeBeginChunked(const QByteArray &mimeType, QHttpServerResponder::StatusCode status = StatusCode::Ok)
MIMEタイプmimeType および指定されたステータスコードstatus を使用して、データのチャンクの送信を開始します。この呼び出しの後には、任意の回数のwriteChunk 呼び出しを繰り返し、その後、writeEndChunked を呼び出す必要があります。
この関数は Qt 6.8 で導入されました。
writeChunk およびwriteEndChunkedも参照してください 。
[since 6.8] void QHttpServerResponder::writeBeginChunked(const QHttpHeaders &headers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
headers およびステータスコードstatus を使用して、データのチャンク送信を開始します。この呼び出しの後には、任意の回数のwriteChunk の呼び出しを繰り返し、最後にwriteEndChunked を 1 回呼び出す必要があります。
この関数は Qt 6.8 で導入されました。
writeChunk およびwriteEndChunkedも参照してください 。
[since 6.8] void QHttpServerResponder::writeBeginChunked(const QHttpHeaders &headers, QList<QHttpHeaders::WellKnownHeader> trailers, QHttpServerResponder::StatusCode status = StatusCode::Ok)
headers および指定されたステータスコードstatus を使用して、データのチャンクの送信を開始します。この呼び出しの後には、任意の回数のwriteChunk の呼び出しを繰り返した後、trailers で指定されたのと同じトレーラーを指定して、writeEndChunked を 1 回呼び出す必要があります。
この関数は Qt 6.8 で導入されました。
writeChunk およびwriteEndChunkedも参照してください 。
[since 6.8] void QHttpServerResponder::writeChunk(const QByteArray &data)
data をクライアントに書き戻します。書き込み可能なデータが用意されたときに呼び出されます。この関数は複数回呼び出される可能性がありますが、呼び出す前にwriteBeginChunked を呼び出し、その後writeEndChunked を呼び出す必要があります。
この関数は Qt 6.8 で導入されました。
writeBeginChunked およびwriteEndChunkedも参照してください 。
[since 6.8] void QHttpServerResponder::writeEndChunked(const QByteArray &data)
data をクライアントに書き戻します。その前に、writeBeginChunked を呼び出す必要があります。
この関数は Qt 6.8 で導入されました。
writeBeginChunked およびwriteChunkも参照してください 。
[since 6.8] void QHttpServerResponder::writeEndChunked(const QByteArray &data, const QHttpHeaders &trailers)
writeBeginChunked で発表されたtrailers を使用して、data をクライアントに書き戻します。
この関数は Qt 6.8 で導入されました。
writeBeginChunked およびwriteChunkも参照してください 。
© 2026 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.