QHttpHeaders Class | Qt Network | Qt 6.11.1
Description: QHttpHeaders is a class for holding HTTP headers.

- Qt 6.11
- Qt Network
- C++ Classes
- QHttpHeaders
- Qt 6.11.1 Reference Documentation

# QHttpHeaders Class

QHttpHeaders is a class for holding HTTP headers. More...

Header: | `#include <QHttpHeaders>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Network)` `target_link_libraries(mytarget PRIVATE Qt6::Network)`
qmake: | `QT += network`
Since: | Qt 6.7

- List of all members, including inherited members

## Public Types

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

## Public Functions

| 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
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)
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)

## Static Public Members

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)

## Related Non-Members

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

## Detailed Description

The class is an interface type for Qt networking APIs that use or consume such headers.

### Allowed field name and value characters

An HTTP header consists of name and value. When setting these, QHttpHeaders validates name and value to only contain characters allowed by the HTTP RFCs. For detailed information see RFC 9110 Chapters 5.1 and 5.5.

In all, this means:

- `name` must consist of visible ASCII characters, and must not be empty
- `value` may consist of arbitrary bytes, as long as header and use case specific encoding rules are adhered to. `value` may be empty

The setters of this class automatically remove any leading or trailing whitespaces from value, as they must be ignored during the value processing.

### Combining values

Most HTTP header values can be combined with a single comma `','` plus an optional whitespace, and the semantic meaning is preserved. As an example, these two should be semantically similar:

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

However, there is a notable exception to this rule: Set-Cookie. Due to this and the possibility of custom use cases, QHttpHeaders does not automatically combine the values.

### Performance

Most QHttpHeaders functions provide both QHttpHeaders::WellKnownHeader and QAnyStringView overloads. From a memory-usage and computation point of view it is recommended to use the QHttpHeaders::WellKnownHeader overloads.

## Member Type Documentation

### enum class QHttpHeaders::WellKnownHeader

List of well known headers as per IANA registry.

Constant | Value
--- | ---
`QHttpHeaders::WellKnownHeader::AIM` | `0`
`QHttpHeaders::WellKnownHeader::Accept` | `1`
`QHttpHeaders::WellKnownHeader::AcceptAdditions` | `2`
`QHttpHeaders::WellKnownHeader::AcceptCH` | `3`
`QHttpHeaders::WellKnownHeader::AcceptDatetime` | `4`
`QHttpHeaders::WellKnownHeader::AcceptEncoding` | `5`
`QHttpHeaders::WellKnownHeader::AcceptFeatures` | `6`
`QHttpHeaders::WellKnownHeader::AcceptLanguage` | `7`
`QHttpHeaders::WellKnownHeader::AcceptPatch` | `8`
`QHttpHeaders::WellKnownHeader::AcceptPost` | `9`
`QHttpHeaders::WellKnownHeader::AcceptRanges` | `10`
`QHttpHeaders::WellKnownHeader::AcceptSignature` | `11`
`QHttpHeaders::WellKnownHeader::AccessControlAllowCredentials` | `12`
`QHttpHeaders::WellKnownHeader::AccessControlAllowHeaders` | `13`
`QHttpHeaders::WellKnownHeader::AccessControlAllowMethods` | `14`
`QHttpHeaders::WellKnownHeader::AccessControlAllowOrigin` | `15`
`QHttpHeaders::WellKnownHeader::AccessControlExposeHeaders` | `16`
`QHttpHeaders::WellKnownHeader::AccessControlMaxAge` | `17`
`QHttpHeaders::WellKnownHeader::AccessControlRequestHeaders` | `18`
`QHttpHeaders::WellKnownHeader::AccessControlRequestMethod` | `19`
`QHttpHeaders::WellKnownHeader::Age` | `20`
`QHttpHeaders::WellKnownHeader::Allow` | `21`
`QHttpHeaders::WellKnownHeader::ALPN` | `22`
`QHttpHeaders::WellKnownHeader::AltSvc` | `23`
`QHttpHeaders::WellKnownHeader::AltUsed` | `24`
`QHttpHeaders::WellKnownHeader::Alternates` | `25`
`QHttpHeaders::WellKnownHeader::ApplyToRedirectRef` | `26`
`QHttpHeaders::WellKnownHeader::AuthenticationControl` | `27`
`QHttpHeaders::WellKnownHeader::AuthenticationInfo` | `28`
`QHttpHeaders::WellKnownHeader::Authorization` | `29`
`QHttpHeaders::WellKnownHeader::CacheControl` | `30`
`QHttpHeaders::WellKnownHeader::CacheStatus` | `31`
`QHttpHeaders::WellKnownHeader::CalManagedID` | `32`
`QHttpHeaders::WellKnownHeader::CalDAVTimezones` | `33`
`QHttpHeaders::WellKnownHeader::CapsuleProtocol` | `34`
`QHttpHeaders::WellKnownHeader::CDNCacheControl` | `35`
`QHttpHeaders::WellKnownHeader::CDNLoop` | `36`
`QHttpHeaders::WellKnownHeader::CertNotAfter` | `37`
`QHttpHeaders::WellKnownHeader::CertNotBefore` | `38`
`QHttpHeaders::WellKnownHeader::ClearSiteData` | `39`
`QHttpHeaders::WellKnownHeader::ClientCert` | `40`
`QHttpHeaders::WellKnownHeader::ClientCertChain` | `41`
`QHttpHeaders::WellKnownHeader::Close` | `42`
`QHttpHeaders::WellKnownHeader::Connection` | `43`
`QHttpHeaders::WellKnownHeader::ContentDigest` | `44`
`QHttpHeaders::WellKnownHeader::ContentDisposition` | `45`
`QHttpHeaders::WellKnownHeader::ContentEncoding` | `46`
`QHttpHeaders::WellKnownHeader::ContentID` | `47`
`QHttpHeaders::WellKnownHeader::ContentLanguage` | `48`
`QHttpHeaders::WellKnownHeader::ContentLength` | `49`
`QHttpHeaders::WellKnownHeader::ContentLocation` | `50`
`QHttpHeaders::WellKnownHeader::ContentRange` | `51`
`QHttpHeaders::WellKnownHeader::ContentSecurityPolicy` | `52`
`QHttpHeaders::WellKnownHeader::ContentSecurityPolicyReportOnly` | `53`
`QHttpHeaders::WellKnownHeader::ContentType` | `54`
`QHttpHeaders::WellKnownHeader::Cookie` | `55`
`QHttpHeaders::WellKnownHeader::CrossOriginEmbedderPolicy` | `56`
`QHttpHeaders::WellKnownHeader::CrossOriginEmbedderPolicyReportOnly` | `57`
`QHttpHeaders::WellKnownHeader::CrossOriginOpenerPolicy` | `58`
`QHttpHeaders::WellKnownHeader::CrossOriginOpenerPolicyReportOnly` | `59`
`QHttpHeaders::WellKnownHeader::CrossOriginResourcePolicy` | `60`
`QHttpHeaders::WellKnownHeader::DASL` | `61`
`QHttpHeaders::WellKnownHeader::Date` | `62`
`QHttpHeaders::WellKnownHeader::DAV` | `63`
`QHttpHeaders::WellKnownHeader::DeltaBase` | `64`
`QHttpHeaders::WellKnownHeader::Depth` | `65`
`QHttpHeaders::WellKnownHeader::Destination` | `66`
`QHttpHeaders::WellKnownHeader::DifferentialID` | `67`
`QHttpHeaders::WellKnownHeader::DPoP` | `68`
`QHttpHeaders::WellKnownHeader::DPoPNonce` | `69`
`QHttpHeaders::WellKnownHeader::EarlyData` | `70`
`QHttpHeaders::WellKnownHeader::ETag` | `71`
`QHttpHeaders::WellKnownHeader::Expect` | `72`
`QHttpHeaders::WellKnownHeader::ExpectCT` | `73`
`QHttpHeaders::WellKnownHeader::Expires` | `74`
`QHttpHeaders::WellKnownHeader::Forwarded` | `75`
`QHttpHeaders::WellKnownHeader::From` | `76`
`QHttpHeaders::WellKnownHeader::Hobareg` | `77`
`QHttpHeaders::WellKnownHeader::Host` | `78`
`QHttpHeaders::WellKnownHeader::If` | `79`
`QHttpHeaders::WellKnownHeader::IfMatch` | `80`
`QHttpHeaders::WellKnownHeader::IfModifiedSince` | `81`
`QHttpHeaders::WellKnownHeader::IfNoneMatch` | `82`
`QHttpHeaders::WellKnownHeader::IfRange` | `83`
`QHttpHeaders::WellKnownHeader::IfScheduleTagMatch` | `84`
`QHttpHeaders::WellKnownHeader::IfUnmodifiedSince` | `85`
`QHttpHeaders::WellKnownHeader::IM` | `86`
`QHttpHeaders::WellKnownHeader::IncludeReferredTokenBindingID` | `87`
`QHttpHeaders::WellKnownHeader::KeepAlive` | `88`
`QHttpHeaders::WellKnownHeader::Label` | `89`
`QHttpHeaders::WellKnownHeader::LastEventID` | `90`
`QHttpHeaders::WellKnownHeader::LastModified` | `91`
`QHttpHeaders::WellKnownHeader::Link` | `92`
`QHttpHeaders::WellKnownHeader::Location` | `93`
`QHttpHeaders::WellKnownHeader::LockToken` | `94`
`QHttpHeaders::WellKnownHeader::MaxForwards` | `95`
`QHttpHeaders::WellKnownHeader::MementoDatetime` | `96`
`QHttpHeaders::WellKnownHeader::Meter` | `97`
`QHttpHeaders::WellKnownHeader::MIMEVersion` | `98`
`QHttpHeaders::WellKnownHeader::Negotiate` | `99`
`QHttpHeaders::WellKnownHeader::NEL` | `100`
`QHttpHeaders::WellKnownHeader::ODataEntityId` | `101`
`QHttpHeaders::WellKnownHeader::ODataIsolation` | `102`
`QHttpHeaders::WellKnownHeader::ODataMaxVersion` | `103`
`QHttpHeaders::WellKnownHeader::ODataVersion` | `104`
`QHttpHeaders::WellKnownHeader::OptionalWWWAuthenticate` | `105`
`QHttpHeaders::WellKnownHeader::OrderingType` | `106`
`QHttpHeaders::WellKnownHeader::Origin` | `107`
`QHttpHeaders::WellKnownHeader::OriginAgentCluster` | `108`
`QHttpHeaders::WellKnownHeader::OSCORE` | `109`
`QHttpHeaders::WellKnownHeader::OSLCCoreVersion` | `110`
`QHttpHeaders::WellKnownHeader::Overwrite` | `111`
`QHttpHeaders::WellKnownHeader::PingFrom` | `112`
`QHttpHeaders::WellKnownHeader::PingTo` | `113`
`QHttpHeaders::WellKnownHeader::Position` | `114`
`QHttpHeaders::WellKnownHeader::Prefer` | `115`
`QHttpHeaders::WellKnownHeader::PreferenceApplied` | `116`
`QHttpHeaders::WellKnownHeader::Priority` | `117`
`QHttpHeaders::WellKnownHeader::ProxyAuthenticate` | `118`
`QHttpHeaders::WellKnownHeader::ProxyAuthenticationInfo` | `119`
`QHttpHeaders::WellKnownHeader::ProxyAuthorization` | `120`
`QHttpHeaders::WellKnownHeader::ProxyStatus` | `121`
`QHttpHeaders::WellKnownHeader::PublicKeyPins` | `122`
`QHttpHeaders::WellKnownHeader::PublicKeyPinsReportOnly` | `123`
`QHttpHeaders::WellKnownHeader::Range` | `124`
`QHttpHeaders::WellKnownHeader::RedirectRef` | `125`
`QHttpHeaders::WellKnownHeader::Referer` | `126`
`QHttpHeaders::WellKnownHeader::Refresh` | `127`
`QHttpHeaders::WellKnownHeader::ReplayNonce` | `128`
`QHttpHeaders::WellKnownHeader::ReprDigest` | `129`
`QHttpHeaders::WellKnownHeader::RetryAfter` | `130`
`QHttpHeaders::WellKnownHeader::ScheduleReply` | `131`
`QHttpHeaders::WellKnownHeader::ScheduleTag` | `132`
`QHttpHeaders::WellKnownHeader::SecPurpose` | `133`
`QHttpHeaders::WellKnownHeader::SecTokenBinding` | `134`
`QHttpHeaders::WellKnownHeader::SecWebSocketAccept` | `135`
`QHttpHeaders::WellKnownHeader::SecWebSocketExtensions` | `136`
`QHttpHeaders::WellKnownHeader::SecWebSocketKey` | `137`
`QHttpHeaders::WellKnownHeader::SecWebSocketProtocol` | `138`
`QHttpHeaders::WellKnownHeader::SecWebSocketVersion` | `139`
`QHttpHeaders::WellKnownHeader::Server` | `140`
`QHttpHeaders::WellKnownHeader::ServerTiming` | `141`
`QHttpHeaders::WellKnownHeader::SetCookie` | `142`
`QHttpHeaders::WellKnownHeader::Signature` | `143`
`QHttpHeaders::WellKnownHeader::SignatureInput` | `144`
`QHttpHeaders::WellKnownHeader::SLUG` | `145`
`QHttpHeaders::WellKnownHeader::SoapAction` | `146`
`QHttpHeaders::WellKnownHeader::StatusURI` | `147`
`QHttpHeaders::WellKnownHeader::StrictTransportSecurity` | `148`
`QHttpHeaders::WellKnownHeader::Sunset` | `149`
`QHttpHeaders::WellKnownHeader::SurrogateCapability` | `150`
`QHttpHeaders::WellKnownHeader::SurrogateControl` | `151`
`QHttpHeaders::WellKnownHeader::TCN` | `152`
`QHttpHeaders::WellKnownHeader::TE` | `153`
`QHttpHeaders::WellKnownHeader::Timeout` | `154`
`QHttpHeaders::WellKnownHeader::Topic` | `155`
`QHttpHeaders::WellKnownHeader::Traceparent` | `156`
`QHttpHeaders::WellKnownHeader::Tracestate` | `157`
`QHttpHeaders::WellKnownHeader::Trailer` | `158`
`QHttpHeaders::WellKnownHeader::TransferEncoding` | `159`
`QHttpHeaders::WellKnownHeader::TTL` | `160`
`QHttpHeaders::WellKnownHeader::Upgrade` | `161`
`QHttpHeaders::WellKnownHeader::Urgency` | `162`
`QHttpHeaders::WellKnownHeader::UserAgent` | `163`
`QHttpHeaders::WellKnownHeader::VariantVary` | `164`
`QHttpHeaders::WellKnownHeader::Vary` | `165`
`QHttpHeaders::WellKnownHeader::Via` | `166`
`QHttpHeaders::WellKnownHeader::WantContentDigest` | `167`
`QHttpHeaders::WellKnownHeader::WantReprDigest` | `168`
`QHttpHeaders::WellKnownHeader::WWWAuthenticate` | `169`
`QHttpHeaders::WellKnownHeader::XContentTypeOptions` | `170`
`QHttpHeaders::WellKnownHeader::XFrameOptions` | `171`
`QHttpHeaders::WellKnownHeader::AcceptCharset` | `172`
`QHttpHeaders::WellKnownHeader::CPEPInfo` | `173`
`QHttpHeaders::WellKnownHeader::Pragma` | `174`
`QHttpHeaders::WellKnownHeader::ProtocolInfo` | `175`
`QHttpHeaders::WellKnownHeader::ProtocolQuery` | `176`

## Member Function Documentation

### `[noexcept]` QHttpHeaders::QHttpHeaders()

Creates a new QHttpHeaders object.

### QHttpHeaders::QHttpHeaders(const QHttpHeaders &other)

Creates a copy of other.

### `[constexpr noexcept]` QHttpHeaders::QHttpHeaders(QHttpHeaders &&other)

Move-constructs the object from other, which will be left empty.

### `[noexcept]` QHttpHeaders::~QHttpHeaders()

Disposes of the headers object.

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

Appends a header entry with name and value and returns `true` if successful.

See also append(QHttpHeaders::WellKnownHeader, QAnyStringView) and Allowed field name and value characters.

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

This function overloads QHttpHeaders::append(QAnyStringView, QAnyStringView).

### void QHttpHeaders::clear()

Clears all header entries.

See also size().

### QByteArray QHttpHeaders::combinedValue(QAnyStringView name) const

Returns the values of header name in a comma-combined string. Returns a `null` QByteArray if the header with name doesn't exist.

Note: Accessing the value(s) of 'Set-Cookie' header this way may not work as intended. It is a notable exception in the HTTP RFC in that its values cannot be combined this way. Prefer values() instead.

See also values(QAnyStringView).

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

This function overloads QHttpHeaders::combinedValue(QAnyStringView).

### bool QHttpHeaders::contains(QAnyStringView name) const

Returns whether the headers contain header with name.

See also contains(QHttpHeaders::WellKnownHeader).

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

This function overloads QHttpHeaders::has(QAnyStringView).

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

Converts the first found header value of name to a QDateTime object, following the standard HTTP date formats. If the header does not exist or contains an invalid QDateTime, returns `std::nullopt`.

This function was introduced in Qt 6.10.

See also setDateTimeValue(), dateTimeValues(QAnyStringView name), and dateTimeValueAt(qsizetype i).

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

This function overloads QHttpHeaders::dateTimeValue(QAnyStringView).

This function was introduced in Qt 6.10.

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

Converts the header value at index i to a QDateTime object following the standard HTTP date formats. The index i must be valid.

This function was introduced in Qt 6.10.

See also dateTimeValue(QAnyStringView name) and dateTimeValues(QAnyStringView name).

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

Returns all the header values of name in a list of QDateTime objects, following the standard HTTP date formats. If no valid date-time values are found, returns `std::nullopt`.

This function was introduced in Qt 6.10.

See also dateTimeValue(QAnyStringView name) and dateTimeValueAt(qsizetype i).

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

This function overloads QHttpHeaders::dateTimeValues(QAnyStringView).

This function was introduced in Qt 6.10.

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

Creates a new QHttpHeaders object that is populated with headers.

See also Allowed field name and value characters.

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

Creates a new QHttpHeaders object that is populated with headers.

See also Allowed field name and value characters.

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

Creates a new QHttpHeaders object that is populated with headers.

See also Allowed field name and value characters.

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

Inserts a header entry at index i, with name and value. The index must be valid (see size()). Returns whether the insert succeeded.

See also append(), insert(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size(), and Allowed field name and value characters.

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

This function overloads QHttpHeaders::insert(qsizetype, QAnyStringView, QAnyStringView).

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

Returns the value of the first valid header name interpreted as a 64-bit integer. If the header does not exist or cannot be parsed as an integer, returns `std::nullopt`.

This function was introduced in Qt 6.10.

See also intValues(QAnyStringView name) and intValueAt(qsizetype i).

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

This function overloads QHttpHeaders::intValue(QAnyStringView).

This function was introduced in Qt 6.10.

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

Returns the header value interpreted as 64-bit integer at index i. The index i must be valid.

This function was introduced in Qt 6.10.

See also intValues(QAnyStringView name) and intValue(QAnyStringView name).

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

Returns the values of the header name interpreted as 64-bit integer in a list. If the header does not exist or cannot be parsed as an integer, returns `std::nullopt`.

This function was introduced in Qt 6.10.

See also intValue(QAnyStringView name) and intValueAt(qsizetype i).

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

This function overloads QHttpHeaders::intValues(QAnyStringView).

This function was introduced in Qt 6.10.

### `[noexcept]` bool QHttpHeaders::isEmpty() const

Returns `true` if the headers have size 0; otherwise returns `false`.

See also size().

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

Returns the header name at index i. The index i must be valid (see size()).

Header names are case-insensitive, and the returned names are lower-cased.

See also size() and valueAt().

### void QHttpHeaders::removeAll(QAnyStringView name)

Removes the header name.

See also removeAt() and removeAll(QHttpHeaders::WellKnownHeader).

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

This function overloads QHttpHeaders::removeAll(QAnyStringView).

### void QHttpHeaders::removeAt(qsizetype i)

Removes the header at index i. The index i must be valid (see size()).

See also removeAll(QHttpHeaders::WellKnownHeader), removeAll(QAnyStringView), and size().

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

Replaces the header entry at index i, with name and newValue. The index must be valid (see size()). Returns whether the replace succeeded.

See also append(), replace(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size(), and Allowed field name and value characters.

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

This function overloads QHttpHeaders::replace(qsizetype, QAnyStringView, QAnyStringView).

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

If QHttpHeaders already contains name, replaces its value with newValue and removes possible additional name entries. If name didn't exist, appends a new entry. Returns `true` if successful.

This function is a convenience method for setting a unique name : newValue header. For most headers the relative order does not matter, which allows reusing an existing entry if one exists.

This function was introduced in Qt 6.8.

See also replaceOrAppend(QAnyStringView, QAnyStringView).

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

This function overloads QHttpHeaders::replaceOrAppend(WellKnownHeader, QAnyStringView).

### void QHttpHeaders::reserve(qsizetype size)

Attempts to allocate memory for at least size header entries.

If you know in advance how how many header entries there will be, you may call this function to prevent reallocations and memory fragmentation.

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

Sets the value of the header name name to dateTime, following the standard HTTP IMF-fixdate format. If the header does not exist, adds a new one.

This function was introduced in Qt 6.10.

See also dateTimeValue(QAnyStringView name) and dateTimeValueAt(qsizetype i).

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

This function overloads QHttpHeaders::setDateTimeValue(QAnyStringView).

This function was introduced in Qt 6.10.

### `[noexcept]` qsizetype QHttpHeaders::size() const

Returns the number of header entries.

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

Swaps this QHttpHeaders with other. This operation is very fast and never fails.

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

Returns the header entries as a list of (name, value) pairs. Header names are case-insensitive, and the returned names are lower-cased.

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

Returns the header entries as a hash from name to value(s). Header names are case-insensitive, and the returned names are lower-cased.

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

Returns the header entries as a map from name to value(s). Header names are case-insensitive, and the returned names are lower-cased.

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

Returns the value of the (first) header name, or defaultValue if it doesn't exist.

See also value(QHttpHeaders::WellKnownHeader, QByteArrayView).

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

This function overloads QHttpHeaders::value(QAnyStringView, QByteArrayView).

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

Returns the header value at index i. The index i must be valid (see size()).

See also size(), value(), values(), combinedValue(), and nameAt().

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

Returns the values of header name in a list. Returns an empty list if header with name doesn't exist.

See also values(QHttpHeaders::WellKnownHeader).

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

This function overloads QHttpHeaders::values(QAnyStringView).

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

Returns a header name corresponding to the provided name as a view.

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

Move-assigns other and returns a reference to this object.

other will be left empty.

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

Assigns the contents of other and returns a reference to this object.

## Related Non-Members

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

Writes headers into debug stream.