このページでは

QHttpHeaders Class

QHttpHeaders は、HTTP ヘッダーを保持するためのクラスです。詳細...

ヘッダー: #include <QHttpHeaders>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network
以下のように: Qt 6.7

パブリック型

enum class WellKnownHeader { AIM, Accept, AcceptAdditions, AcceptCH, AcceptDatetime, …, ProtocolQuery }

パブリック関数

QHttpHeaders()
QHttpHeaders(const QHttpHeaders &other)
QHttpHeaders(QHttpHeaders &&other)
~QHttpHeaders()
bool append(QAnyStringView name, QAnyStringView value)
bool append(QHttpHeaders::WellKnownHeader name, QAnyStringView value)
void clear()
QByteArray combinedValue(QAnyStringView name) const
QByteArray combinedValue(QHttpHeaders::WellKnownHeader name) const
bool contains(QAnyStringView name) const
bool contains(QHttpHeaders::WellKnownHeader name) const
(since 6.10) std::optional<QDateTime> dateTimeValue(QAnyStringView name) const
(since 6.10) std::optional<QDateTime> dateTimeValue(QHttpHeaders::WellKnownHeader name) const
(since 6.10) std::optional<QDateTime> dateTimeValueAt(qsizetype i) const
(since 6.10) std::optional<QList<QDateTime>> dateTimeValues(QAnyStringView name) const
(since 6.10) std::optional<QList<QDateTime>> dateTimeValues(QHttpHeaders::WellKnownHeader name) const
bool insert(qsizetype i, QAnyStringView name, QAnyStringView value)
bool insert(qsizetype i, QHttpHeaders::WellKnownHeader name, QAnyStringView value)
(since 6.10) std::optional<qint64> intValue(QAnyStringView name) const
(since 6.10) std::optional<qint64> intValue(QHttpHeaders::WellKnownHeader name) const
(since 6.10) std::optional<qint64> intValueAt(qsizetype i) const
(since 6.10) std::optional<QList<qint64>> intValues(QAnyStringView name) const
(since 6.10) std::optional<QList<qint64>> intValues(QHttpHeaders::WellKnownHeader name) const
bool isEmpty() const
QLatin1StringView nameAt(qsizetype i) const
(since 6.12) std::optional<QHttpHeaderRangeSet> rangeValues() const
void removeAll(QAnyStringView name)
void removeAll(QHttpHeaders::WellKnownHeader name)
void removeAt(qsizetype i)
bool replace(qsizetype i, QAnyStringView name, QAnyStringView newValue)
bool replace(qsizetype i, QHttpHeaders::WellKnownHeader name, QAnyStringView newValue)
(since 6.8) bool replaceOrAppend(QHttpHeaders::WellKnownHeader name, QAnyStringView newValue)
bool replaceOrAppend(QAnyStringView name, QAnyStringView newValue)
void reserve(qsizetype size)
(since 6.10) void setDateTimeValue(QAnyStringView name, const QDateTime &dateTime)
(since 6.10) void setDateTimeValue(QHttpHeaders::WellKnownHeader name, const QDateTime &dateTime)
(since 6.12) void setRangeValues(const QHttpHeaderRangeSet &ranges)
qsizetype size() const
void swap(QHttpHeaders &other)
QList<std::pair<QByteArray, QByteArray>> toListOfPairs() const
QMultiHash<QByteArray, QByteArray> toMultiHash() const
QMultiMap<QByteArray, QByteArray> toMultiMap() const
QByteArrayView value(QAnyStringView name, QByteArrayView defaultValue = {}) const
QByteArrayView value(QHttpHeaders::WellKnownHeader name, QByteArrayView defaultValue = {}) const
QByteArrayView valueAt(qsizetype i) const
QList<QByteArray> values(QAnyStringView name) const
QList<QByteArray> values(QHttpHeaders::WellKnownHeader name) const
QHttpHeaders &operator=(QHttpHeaders &&other)
QHttpHeaders &operator=(const QHttpHeaders &other)

静的パブリックメンバー

QHttpHeaders fromListOfPairs(const QList<std::pair<QByteArray, QByteArray>> &headers)
QHttpHeaders fromMultiHash(const QMultiHash<QByteArray, QByteArray> &headers)
QHttpHeaders fromMultiMap(const QMultiMap<QByteArray, QByteArray> &headers)
QByteArrayView wellKnownHeaderName(QHttpHeaders::WellKnownHeader name)
(since 6.12) QDataStream &operator<<(QDataStream &out, const QHttpHeaders &headers)
QDebug operator<<(QDebug debug, const QHttpHeaders &headers)
(since 6.12) QDataStream &operator>>(QDataStream &in, QHttpHeaders &headers)

詳細な説明

このクラスは、そのようなヘッダーを使用または消費する Qt Network API 用のインターフェース型です。

フィールド名および値に使用可能な文字

HTTPヘッダーは、名前と値で構成されます。これらを設定する際、QHttpHeadersは、名前と値にHTTP RFCで許可されている文字のみが含まれていることを検証します。詳細については、RFC 9110の第5.1章および第5.5章を参照してください。

要するに、これは次のことを意味します:

  • name 可視ASCII文字で構成されていなければならず、空であってはなりません
  • value ヘッダーおよびユースケース固有のエンコード規則が遵守されている限り、任意のバイトで構成されてもよい。value は空でもよい

このクラスのセッターは、値の処理中に無視される必要があるため、値の先頭または末尾にある空白文字を自動的に削除します。

値の結合

ほとんどの HTTP ヘッダー値は、単一のコンマ「',' 」と(オプションの)空白を挟んで結合することができ、その際、意味的な内容は保持されます。例として、次の 2 つは意味的に類似しているはずです:

// Values as separate header entries
myheadername: myheadervalue1
myheadername: myheadervalue2
// Combined value
myheadername: myheadervalue1, myheadervalue2

ただし、このルールには注目すべき例外があります。それはSet-Cookie です。この点およびカスタムユースケースの可能性を考慮し、QHttpHeaders では値を自動的に結合しません。

パフォーマンス

QHttpHeadersの関数のほとんどは、QHttpHeaders::WellKnownHeader とQAnyStringView の両方のオーバーロードを提供しています。メモリ使用量および計算量の観点から、QHttpHeaders::WellKnownHeader のオーバーロードを使用することを推奨します。

メンバ型のドキュメント

enum class QHttpHeaders::WellKnownHeader

IANAレジストリに基づく、よく知られたヘッダーの一覧。

定数値
QHttpHeaders::WellKnownHeader::AIM0
QHttpHeaders::WellKnownHeader::Accept1
QHttpHeaders::WellKnownHeader::AcceptAdditions2
QHttpHeaders::WellKnownHeader::AcceptCH3
QHttpHeaders::WellKnownHeader::AcceptDatetime4
QHttpHeaders::WellKnownHeader::AcceptEncoding5
QHttpHeaders::WellKnownHeader::AcceptFeatures6
QHttpHeaders::WellKnownHeader::AcceptLanguage7
QHttpHeaders::WellKnownHeader::AcceptPatch8
QHttpHeaders::WellKnownHeader::AcceptPost9
QHttpHeaders::WellKnownHeader::AcceptRanges10
QHttpHeaders::WellKnownHeader::AcceptSignature11
QHttpHeaders::WellKnownHeader::AccessControlAllowCredentials12
QHttpHeaders::WellKnownHeader::AccessControlAllowHeaders13
QHttpHeaders::WellKnownHeader::AccessControlAllowMethods14
QHttpHeaders::WellKnownHeader::AccessControlAllowOrigin15
QHttpHeaders::WellKnownHeader::AccessControlExposeHeaders16
QHttpHeaders::WellKnownHeader::AccessControlMaxAge17
QHttpHeaders::WellKnownHeader::AccessControlRequestHeaders18
QHttpHeaders::WellKnownHeader::AccessControlRequestMethod19
QHttpHeaders::WellKnownHeader::Age20
QHttpHeaders::WellKnownHeader::Allow21
QHttpHeaders::WellKnownHeader::ALPN22
QHttpHeaders::WellKnownHeader::AltSvc23
QHttpHeaders::WellKnownHeader::AltUsed24
QHttpHeaders::WellKnownHeader::Alternates25
QHttpHeaders::WellKnownHeader::ApplyToRedirectRef26
QHttpHeaders::WellKnownHeader::AuthenticationControl27
QHttpHeaders::WellKnownHeader::AuthenticationInfo28
QHttpHeaders::WellKnownHeader::Authorization29
QHttpHeaders::WellKnownHeader::CacheControl30
QHttpHeaders::WellKnownHeader::CacheStatus31
QHttpHeaders::WellKnownHeader::CalManagedID32
QHttpHeaders::WellKnownHeader::CalDAVTimezones33
QHttpHeaders::WellKnownHeader::CapsuleProtocol34
QHttpHeaders::WellKnownHeader::CDNCacheControl35
QHttpHeaders::WellKnownHeader::CDNLoop36
QHttpHeaders::WellKnownHeader::CertNotAfter37
QHttpHeaders::WellKnownHeader::CertNotBefore38
QHttpHeaders::WellKnownHeader::ClearSiteData39
QHttpHeaders::WellKnownHeader::ClientCert40
QHttpHeaders::WellKnownHeader::ClientCertChain41
QHttpHeaders::WellKnownHeader::Close42
QHttpHeaders::WellKnownHeader::Connection43
QHttpHeaders::WellKnownHeader::ContentDigest44
QHttpHeaders::WellKnownHeader::ContentDisposition45
QHttpHeaders::WellKnownHeader::ContentEncoding46
QHttpHeaders::WellKnownHeader::ContentID47
QHttpHeaders::WellKnownHeader::ContentLanguage48
QHttpHeaders::WellKnownHeader::ContentLength49
QHttpHeaders::WellKnownHeader::ContentLocation50
QHttpHeaders::WellKnownHeader::ContentRange51
QHttpHeaders::WellKnownHeader::ContentSecurityPolicy52
QHttpHeaders::WellKnownHeader::ContentSecurityPolicyReportOnly53
QHttpHeaders::WellKnownHeader::ContentType54
QHttpHeaders::WellKnownHeader::Cookie55
QHttpHeaders::WellKnownHeader::CrossOriginEmbedderPolicy56
QHttpHeaders::WellKnownHeader::CrossOriginEmbedderPolicyReportOnly57
QHttpHeaders::WellKnownHeader::CrossOriginOpenerPolicy58
QHttpHeaders::WellKnownHeader::CrossOriginOpenerPolicyReportOnly59
QHttpHeaders::WellKnownHeader::CrossOriginResourcePolicy60
QHttpHeaders::WellKnownHeader::DASL61
QHttpHeaders::WellKnownHeader::Date62
QHttpHeaders::WellKnownHeader::DAV63
QHttpHeaders::WellKnownHeader::DeltaBase64
QHttpHeaders::WellKnownHeader::Depth65
QHttpHeaders::WellKnownHeader::Destination66
QHttpHeaders::WellKnownHeader::DifferentialID67
QHttpHeaders::WellKnownHeader::DPoP68
QHttpHeaders::WellKnownHeader::DPoPNonce69
QHttpHeaders::WellKnownHeader::EarlyData70
QHttpHeaders::WellKnownHeader::ETag71
QHttpHeaders::WellKnownHeader::Expect72
QHttpHeaders::WellKnownHeader::ExpectCT73
QHttpHeaders::WellKnownHeader::Expires74
QHttpHeaders::WellKnownHeader::Forwarded75
QHttpHeaders::WellKnownHeader::From76
QHttpHeaders::WellKnownHeader::Hobareg77
QHttpHeaders::WellKnownHeader::Host78
QHttpHeaders::WellKnownHeader::If79
QHttpHeaders::WellKnownHeader::IfMatch80
QHttpHeaders::WellKnownHeader::IfModifiedSince81
QHttpHeaders::WellKnownHeader::IfNoneMatch82
QHttpHeaders::WellKnownHeader::IfRange83
QHttpHeaders::WellKnownHeader::IfScheduleTagMatch84
QHttpHeaders::WellKnownHeader::IfUnmodifiedSince85
QHttpHeaders::WellKnownHeader::IM86
QHttpHeaders::WellKnownHeader::IncludeReferredTokenBindingID87
QHttpHeaders::WellKnownHeader::KeepAlive88
QHttpHeaders::WellKnownHeader::Label89
QHttpHeaders::WellKnownHeader::LastEventID90
QHttpHeaders::WellKnownHeader::LastModified91
QHttpHeaders::WellKnownHeader::Link92
QHttpHeaders::WellKnownHeader::Location93
QHttpHeaders::WellKnownHeader::LockToken94
QHttpHeaders::WellKnownHeader::MaxForwards95
QHttpHeaders::WellKnownHeader::MementoDatetime96
QHttpHeaders::WellKnownHeader::Meter97
QHttpHeaders::WellKnownHeader::MIMEVersion98
QHttpHeaders::WellKnownHeader::Negotiate99
QHttpHeaders::WellKnownHeader::NEL100
QHttpHeaders::WellKnownHeader::ODataEntityId101
QHttpHeaders::WellKnownHeader::ODataIsolation102
QHttpHeaders::WellKnownHeader::ODataMaxVersion103
QHttpHeaders::WellKnownHeader::ODataVersion104
QHttpHeaders::WellKnownHeader::OptionalWWWAuthenticate105
QHttpHeaders::WellKnownHeader::OrderingType106
QHttpHeaders::WellKnownHeader::Origin107
QHttpHeaders::WellKnownHeader::OriginAgentCluster108
QHttpHeaders::WellKnownHeader::OSCORE109
QHttpHeaders::WellKnownHeader::OSLCCoreVersion110
QHttpHeaders::WellKnownHeader::Overwrite111
QHttpHeaders::WellKnownHeader::PingFrom112
QHttpHeaders::WellKnownHeader::PingTo113
QHttpHeaders::WellKnownHeader::Position114
QHttpHeaders::WellKnownHeader::Prefer115
QHttpHeaders::WellKnownHeader::PreferenceApplied116
QHttpHeaders::WellKnownHeader::Priority117
QHttpHeaders::WellKnownHeader::ProxyAuthenticate118
QHttpHeaders::WellKnownHeader::ProxyAuthenticationInfo119
QHttpHeaders::WellKnownHeader::ProxyAuthorization120
QHttpHeaders::WellKnownHeader::ProxyStatus121
QHttpHeaders::WellKnownHeader::PublicKeyPins122
QHttpHeaders::WellKnownHeader::PublicKeyPinsReportOnly123
QHttpHeaders::WellKnownHeader::Range124
QHttpHeaders::WellKnownHeader::RedirectRef125
QHttpHeaders::WellKnownHeader::Referer126
QHttpHeaders::WellKnownHeader::Refresh127
QHttpHeaders::WellKnownHeader::ReplayNonce128
QHttpHeaders::WellKnownHeader::ReprDigest129
QHttpHeaders::WellKnownHeader::RetryAfter130
QHttpHeaders::WellKnownHeader::ScheduleReply131
QHttpHeaders::WellKnownHeader::ScheduleTag132
QHttpHeaders::WellKnownHeader::SecPurpose133
QHttpHeaders::WellKnownHeader::SecTokenBinding134
QHttpHeaders::WellKnownHeader::SecWebSocketAccept135
QHttpHeaders::WellKnownHeader::SecWebSocketExtensions136
QHttpHeaders::WellKnownHeader::SecWebSocketKey137
QHttpHeaders::WellKnownHeader::SecWebSocketProtocol138
QHttpHeaders::WellKnownHeader::SecWebSocketVersion139
QHttpHeaders::WellKnownHeader::Server140
QHttpHeaders::WellKnownHeader::ServerTiming141
QHttpHeaders::WellKnownHeader::SetCookie142
QHttpHeaders::WellKnownHeader::Signature143
QHttpHeaders::WellKnownHeader::SignatureInput144
QHttpHeaders::WellKnownHeader::SLUG145
QHttpHeaders::WellKnownHeader::SoapAction146
QHttpHeaders::WellKnownHeader::StatusURI147
QHttpHeaders::WellKnownHeader::StrictTransportSecurity148
QHttpHeaders::WellKnownHeader::Sunset149
QHttpHeaders::WellKnownHeader::SurrogateCapability150
QHttpHeaders::WellKnownHeader::SurrogateControl151
QHttpHeaders::WellKnownHeader::TCN152
QHttpHeaders::WellKnownHeader::TE153
QHttpHeaders::WellKnownHeader::Timeout154
QHttpHeaders::WellKnownHeader::Topic155
QHttpHeaders::WellKnownHeader::Traceparent156
QHttpHeaders::WellKnownHeader::Tracestate157
QHttpHeaders::WellKnownHeader::Trailer158
QHttpHeaders::WellKnownHeader::TransferEncoding159
QHttpHeaders::WellKnownHeader::TTL160
QHttpHeaders::WellKnownHeader::Upgrade161
QHttpHeaders::WellKnownHeader::Urgency162
QHttpHeaders::WellKnownHeader::UserAgent163
QHttpHeaders::WellKnownHeader::VariantVary164
QHttpHeaders::WellKnownHeader::Vary165
QHttpHeaders::WellKnownHeader::Via166
QHttpHeaders::WellKnownHeader::WantContentDigest167
QHttpHeaders::WellKnownHeader::WantReprDigest168
QHttpHeaders::WellKnownHeader::WWWAuthenticate169
QHttpHeaders::WellKnownHeader::XContentTypeOptions170
QHttpHeaders::WellKnownHeader::XFrameOptions171
QHttpHeaders::WellKnownHeader::AcceptCharset172
QHttpHeaders::WellKnownHeader::CPEPInfo173
QHttpHeaders::WellKnownHeader::Pragma174
QHttpHeaders::WellKnownHeader::ProtocolInfo175
QHttpHeaders::WellKnownHeader::ProtocolQuery176

メンバ関数のドキュメント

[noexcept] QHttpHeaders::QHttpHeaders()

新しい QHttpHeaders オブジェクトを作成します。

QHttpHeaders::QHttpHeaders(const QHttpHeaders &other)

other のコピーを作成します。

[constexpr noexcept default] QHttpHeaders::QHttpHeaders(QHttpHeaders &&other)

other からオブジェクトをムーブコンストラクトで生成します。これにより、 はempty のまま残ります。

[noexcept] QHttpHeaders::~QHttpHeaders()

ヘッダーオブジェクトを破棄します。

bool QHttpHeaders::append(QAnyStringView name, QAnyStringView value)

name およびvalue を含むヘッダーエントリを追加し、成功した場合はtrue を返します。

append(QHttpHeaders::WellKnownHeader, QAnyStringView) およびAllowed field name and value charactersも参照してください 。

bool QHttpHeaders::append(QHttpHeaders::WellKnownHeader name, QAnyStringView value)

この関数は、QHttpHeaders::append(QAnyStringView, QAnyStringView) をオーバーロードしています。

void QHttpHeaders::clear()

すべてのヘッダーエントリをクリアします。

size()も参照してください 。

QByteArray QHttpHeaders::combinedValue(QAnyStringView name) const

ヘッダー「name 」の値をカンマ区切りの文字列として返します。name を含むヘッダーが存在しない場合は、null QByteArray を返します。

注: この方法で「Set-Cookie」ヘッダーの値にアクセスしても 、意図したとおりに動作しない場合があります。このヘッダーの値は、HTTP RFCにおいてこの方法で結合できないという点で、特筆すべき例外となっています。代わりにvalues() を使用することを推奨します。

values(QAnyStringView)も参照してください 。

QByteArray QHttpHeaders::combinedValue(QHttpHeaders::WellKnownHeader name) const

この関数は、QHttpHeaders::combinedValue (QAnyStringView)をオーバーロードしています。

bool QHttpHeaders::contains(QAnyStringView name) const

ヘッダーにname を含むヘッダーが含まれているかどうかを返します。

「contains(QHttpHeaders::WellKnownHeader)」も参照してください 。

bool QHttpHeaders::contains(QHttpHeaders::WellKnownHeader name) const

この関数は、QHttpHeaders::has(QAnyStringView) をオーバーロードしています。

[since 6.10] std::optional<QDateTime> QHttpHeaders::dateTimeValue(QAnyStringView name) const

name のヘッダー値のうち、最初に検出されたものを、標準のHTTP日付形式に従ってQDateTime オブジェクトに変換します。ヘッダーが存在しない場合、または無効なQDateTime が含まれている場合は、std::nullopt を返します。

この関数は Qt 6.10 で導入されました。

setDateTimeValue()、dateTimeValues(QAnyStringView name)、およびdateTimeValueAt(qsizetype i)も参照してください 。

[since 6.10] std::optional<QDateTime> QHttpHeaders::dateTimeValue(QHttpHeaders::WellKnownHeader name) const

この関数は、QHttpHeaders::dateTimeValue (QAnyStringView)をオーバーロードしています。

この関数は Qt 6.10 で導入されました。

[since 6.10] std::optional<QDateTime> QHttpHeaders::dateTimeValueAt(qsizetype i) const

インデックスi にあるヘッダーの値を、標準のHTTP日付形式に従ったQDateTime オブジェクトに変換します。インデックスi は有効な値でなければなりません。

この関数は Qt 6.10 で導入されました。

dateTimeValue (QAnyStringView name)およびdateTimeValues (QAnyStringView name)も参照してください 。

[since 6.10] std::optional<QList<QDateTime>> QHttpHeaders::dateTimeValues(QAnyStringView name) const

name のすべてのヘッダー値を、標準の HTTP 日付形式に従ったQDateTime オブジェクトのリストとして返します。有効な日時値が見つからない場合は、std::nullopt を返します。

この関数は Qt 6.10 で導入されました。

dateTimeValue(QAnyStringView name) およびdateTimeValueAt(qsizetype i)も参照してください 。

[since 6.10] std::optional<QList<QDateTime>> QHttpHeaders::dateTimeValues(QHttpHeaders::WellKnownHeader name) const

この関数は、QHttpHeaders::dateTimeValues (QAnyStringView)をオーバーロードしています。

この関数は Qt 6.10 で導入されました。

[static] QHttpHeaders QHttpHeaders::fromListOfPairs(const QList<std::pair<QByteArray, QByteArray>> &headers)

headers で初期化された新しいQHttpHeaders オブジェクトを作成します。

「Allowed field name and value characters」も参照してください 。

[static] QHttpHeaders QHttpHeaders::fromMultiHash(const QMultiHash<QByteArray, QByteArray> &headers)

headers が設定された新しい `QHttpHeaders ` オブジェクトを作成します。

「Allowed field name and value characters」も参照してください 。

[static] QHttpHeaders QHttpHeaders::fromMultiMap(const QMultiMap<QByteArray, QByteArray> &headers)

headers で初期化された新しいQHttpHeaders オブジェクトを作成します。

「Allowed field name and value characters」も参照してください 。

bool QHttpHeaders::insert(qsizetype i, QAnyStringView name, QAnyStringView value)

インデックスi に、name およびvalue を持つヘッダーエントリを挿入します。インデックスは有効である必要があります(size() を参照)。挿入が成功したかどうかを返します。

append()、insert(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView)、size()、およびAllowed field name and value charactersも参照してください 。

bool QHttpHeaders::insert(qsizetype i, QHttpHeaders::WellKnownHeader name, QAnyStringView value)

この関数は、QHttpHeaders::insert (qsizetype、QAnyStringView、QAnyStringView)をオーバーロードしています。

[noexcept, since 6.10] std::optional<qint64> QHttpHeaders::intValue(QAnyStringView name) const

最初の有効なヘッダー `name ` の値を、64ビット整数として解釈したものを返します。ヘッダーが存在しない場合、または整数として解析できない場合は、std::nullopt を返します。

この関数は Qt 6.10 で導入されました。

intValues(QAnyStringView name) およびintValueAt(qsizetype i)も参照してください 。

[noexcept, since 6.10] std::optional<qint64> QHttpHeaders::intValue(QHttpHeaders::WellKnownHeader name) const

この関数は、QHttpHeaders::intValue (QAnyStringView)をオーバーロードしています。

この関数は Qt 6.10 で導入されました。

[noexcept, since 6.10] std::optional<qint64> QHttpHeaders::intValueAt(qsizetype i) const

インデックス `i` にあるヘッダー値を、64ビット整数として解釈して返します。インデックス `i ` は有効な値でなければなりません。

この関数は Qt 6.10 で導入されました。

intValues(QAnyStringView name) およびintValue(QAnyStringView name)も参照してください 。

[since 6.10] std::optional<QList<qint64>> QHttpHeaders::intValues(QAnyStringView name) const

ヘッダー `name ` の値を、64ビット整数として解釈したものをリストとして返します。ヘッダーが存在しない場合、または整数として解析できない場合は、std::nullopt を返します。

この関数は Qt 6.10 で導入されました。

intValue(QAnyStringView name) およびintValueAt(qsizetype i)も参照してください 。

[since 6.10] std::optional<QList<qint64>> QHttpHeaders::intValues(QHttpHeaders::WellKnownHeader name) const

この関数は、QHttpHeaders::intValues (QAnyStringView)をオーバーロードしています。

この関数は Qt 6.10 で導入されました。

[noexcept] bool QHttpHeaders::isEmpty() const

ヘッダーのサイズが 0 の場合は `true ` を返し、それ以外の場合は `false` を返します。

size()も参照してください 。

[noexcept] QLatin1StringView QHttpHeaders::nameAt(qsizetype i) const

インデックス `i` にあるヘッダー名を返します。インデックス `i ` は有効な値でなければなりません(size() を参照)。

ヘッダー名は大文字と小文字を区別せず、返される名前は小文字に変換されます。

size() およびvalueAt()も参照してください 。

[since 6.12] std::optional<QHttpHeaderRangeSet> QHttpHeaders::rangeValues() const

Range HTTPヘッダーフィールドの範囲を返します。解析に失敗した場合は、std::nullopt を返します。

各範囲はバイト範囲を表します。RFC 9110によると:

  • 開始位置が指定されているが終了位置が指定されていない場合(例: "bytes=500-")、QHttpHeaderRangeSpec にはstart=500 およびend=std::nullopt が設定されます。
  • 終了位置が指定され、開始位置が指定されていない場合(例: "bytes=-500")、QHttpHeaderRangeSpec にはstart=std::nullopt およびend=500 が設定され、最後の500バイトを表します。
  • 両方が指定されている場合(例:「bytes=0-499」)、QHttpHeaderRangeSpec にはstart=0 およびend=499 が含まれます。

範囲は、ヘッダーに記述されている順序で返されます。

解析は次のように行われます。

  • Range ヘッダーが存在しない場合、空の範囲セットが返されます。
  • RFC 9110のセクション14.2によると、「bytes」以外の単位を含むRange ヘッダー(例: 「seconds=1-2」)は無視されます。これらの無視されたヘッダーによって、解析が失敗することはありません。
  • Range ヘッダーが「bytes」単位を使用しているものの、形式が不正である場合(例:ハイフンが欠落している、無効な文字が含まれている、または無効な数値が含まれている)、この関数はstd::nullopt を返します。

この関数は Qt 6.12 で導入されました。

setRangeValues およびWellKnownHeader::Rangeも参照してください 。

void QHttpHeaders::removeAll(QAnyStringView name)

ヘッダー「name 」を削除します。

removeAt() およびremoveAll(QHttpHeaders::WellKnownHeader)も参照してください 。

void QHttpHeaders::removeAll(QHttpHeaders::WellKnownHeader name)

この関数は、QHttpHeaders::removeAll (QAnyStringView)をオーバーロードしています。

void QHttpHeaders::removeAt(qsizetype i)

インデックスi にあるヘッダーを削除します。インデックスi は有効なものでなければなりません(size() を参照してください)。

removeAll(QHttpHeaders::WellKnownHeader)、removeAll(QAnyStringView)、およびsize()も参照してください 。

bool QHttpHeaders::replace(qsizetype i, QAnyStringView name, QAnyStringView newValue)

インデックスi にあるヘッダーエントリを、name およびnewValue に置き換えます。インデックスは有効である必要があります(size() を参照)。置換が成功したかどうかを返します。

append()、replace(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView)、size()、およびAllowed field name and value charactersも参照してください 。

bool QHttpHeaders::replace(qsizetype i, QHttpHeaders::WellKnownHeader name, QAnyStringView newValue)

この関数は、QHttpHeaders::replace (qsizetype、QAnyStringView、QAnyStringView)をオーバーロードしています。

[since 6.8] bool QHttpHeaders::replaceOrAppend(QHttpHeaders::WellKnownHeader name, QAnyStringView newValue)

QHttpHeaders にすでにname が含まれている場合、その値をnewValue に置き換え、追加されている可能性のあるname エントリを削除します。name が存在しない場合は、新しいエントリを追加します。成功した場合はtrue を返します。

この関数は、一意のname:newValue ヘッダーを設定するための便宜的なメソッドです。ほとんどのヘッダーでは順序は重要ではないため、既存のエントリが存在する場合はそれを再利用できます。

この関数は Qt 6.8 で導入されました。

replaceOrAppend(QAnyStringView, QAnyStringView)も参照してください 。

bool QHttpHeaders::replaceOrAppend(QAnyStringView name, QAnyStringView newValue)

この関数は、QHttpHeaders::replaceOrAppend(WellKnownHeader, QAnyStringView) をオーバーロードしています。

void QHttpHeaders::reserve(qsizetype size)

少なくともsize 個のヘッダーエントリ分のメモリを割り当てようとします。

ヘッダーエントリの数が事前に分かっている場合は、この関数を呼び出すことで、再割り当てやメモリの断片化を防ぐことができます。

[since 6.10] void QHttpHeaders::setDateTimeValue(QAnyStringView name, const QDateTime &dateTime)

ヘッダー名「name 」の値を、標準のHTTP IMF-fixdate形式に従って「dateTime 」に設定します。ヘッダーが存在しない場合は、新しいヘッダーを追加します。

この関数は Qt 6.10 で導入されました。

dateTimeValue(QAnyStringView name) およびdateTimeValueAt(qsizetype i)も参照してください 。

[since 6.10] void QHttpHeaders::setDateTimeValue(QHttpHeaders::WellKnownHeader name, const QDateTime &dateTime)

この関数は、QHttpHeaders::setDateTimeValue(QAnyStringView) をオーバーロードしています。

この関数は Qt 6.10 で導入されました。

[since 6.12] void QHttpHeaders::setRangeValues(const QHttpHeaderRangeSet &ranges)

Range HTTPヘッダーフィールドを、指定されたranges のリストに設定します。

範囲は「バイト」単位で、ranges が保持している順序でフォーマットされます。各QHttpHeaderRangeSpec について:

  • 開始値のみを持つ範囲(例:QHttpHeaderRangeSpec(500, std::nullopt))は、"500-" としてフォーマットされます。
  • 終了値のみを含む範囲(例:QHttpHeaderRangeSpec(std::nullopt, 500))は、"-500" としてフォーマットされ、最後の 500 バイトを表します。
  • 開始位置と終了位置の両方が指定されている範囲(例:QHttpHeaderRangeSpec(0, 499))は、"0-499" の形式で表示されます。

複数の範囲が指定された場合、それらはコンマで区切られます。例:"bytes=0-499 、1000-」。

ranges が空の場合、Range ヘッダーは削除されます。

この関数は Qt 6.12 で導入されました。

rangeValues() およびWellKnownHeader::Rangeも参照してください 。

[noexcept] qsizetype QHttpHeaders::size() const

ヘッダーエントリの数を返します。

[noexcept] void QHttpHeaders::swap(QHttpHeaders &other)

QHttpHeaders をother に置き換えます。この処理は非常に高速で、失敗することはありません。

QList<std::pair<QByteArray, QByteArray>> QHttpHeaders::toListOfPairs() const

ヘッダーエントリを (名前, 値) のペアのリストとして返します。ヘッダー名は大文字と小文字を区別せず、返される名前はすべて小文字に変換されます。

QMultiHash<QByteArray, QByteArray> QHttpHeaders::toMultiHash() const

ヘッダーエントリを、名前から値(複数可)へのハッシュとして返します。ヘッダー名は大文字小文字を区別せず、返される名前はすべて小文字に変換されます。

QMultiMap<QByteArray, QByteArray> QHttpHeaders::toMultiMap() const

ヘッダーエントリを、名前から値(複数可)へのマップとして返します。ヘッダー名は大文字と小文字を区別せず、返される名前は小文字に変換されます。

[noexcept] QByteArrayView QHttpHeaders::value(QAnyStringView name, QByteArrayView defaultValue = {}) const

(最初の)ヘッダー `name` の値を返します。存在しない場合は `defaultValue ` を返します。

value(QHttpHeaders::WellKnownHeader、QByteArrayView)も参照してください 。

[noexcept] QByteArrayView QHttpHeaders::value(QHttpHeaders::WellKnownHeader name, QByteArrayView defaultValue = {}) const

この関数は、QHttpHeaders::value (QAnyStringView、QByteArrayView)をオーバーロードしています。

[noexcept] QByteArrayView QHttpHeaders::valueAt(qsizetype i) const

インデックスi にあるヘッダー値を返します。インデックスi は有効な値でなければなりません(size() を参照)。

size()、value()、values()、combinedValue()、およびnameAt()も参照してください 。

QList<QByteArray> QHttpHeaders::values(QAnyStringView name) const

ヘッダー「name 」の値をリストとして返します。name を持つヘッダーが存在しない場合は、空のリストを返します。

values(QHttpHeaders::WellKnownHeader)も参照してください 。

QList<QByteArray> QHttpHeaders::values(QHttpHeaders::WellKnownHeader name) const

この関数は、QHttpHeaders::values (QAnyStringView)をオーバーロードしています。

[static noexcept] QByteArrayView QHttpHeaders::wellKnownHeaderName(QHttpHeaders::WellKnownHeader name)

指定されたname に対応するヘッダー名を、ビューとして返します。

[noexcept] QHttpHeaders &QHttpHeaders::operator=(QHttpHeaders &&other)

other を代入し、このオブジェクトへの参照を返します。

other empty が残されます。

QHttpHeaders &QHttpHeaders::operator=(const QHttpHeaders &other)

other の内容を割り当て、このオブジェクトへの参照を返します。

関連する非メンバー関数

[since 6.12] QDataStream &operator<<(QDataStream &out, const QHttpHeaders &headers)

`headers ` を `out ` ストリームに書き込みます。

この関数は Qt 6.12 で導入されました。

「Qt データ型のシリアライズ」も参照してください 。

QDebug operator<<(QDebug debug, const QHttpHeaders &headers)

headers をdebug のストリームに書き込みます。

[since 6.12] QDataStream &operator>>(QDataStream &in, QHttpHeaders &headers)

ストリーム `in ` からヘッダーを読み取り、`headers` に格納します。

この関数は Qt 6.12 で導入されました。

「Qt データ型のシリアライズ」も参照してください 。

© 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.