Sur cette page

QHttpHeaders Class

QHttpHeaders est une classe qui contient les en-têtes HTTP. Plus d'informations...

En-tête : #include <QHttpHeaders>
CMake : find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake : QT += network
Depuis : Qt 6.7

Types publics

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

Fonctions publiques

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)

Membres publics statiques

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)
QDebug operator<<(QDebug debug, const QHttpHeaders &headers)

Description détaillée

Cette classe est un type d'interface pour les API de Qt Network qui utilisent ou consomment de tels en-têtes.

Caractères autorisés pour le nom et la valeur du champ

Un en-tête HTTP se compose d'un nom et d'une valeur. Lors de leur définition, QHttpHeaders valide le nom et la valeur pour qu'ils ne contiennent que des caractères autorisés par les RFC HTTP. Pour des informations détaillées, voir les chapitres 5.1 et 5.5 de la RFC 9110.

En résumé, cela signifie que :

  • name doit être composé de caractères ASCII visibles et ne doit pas être vide
  • value peut être composé d'octets arbitraires, tant que les règles de codage spécifiques à l'en-tête et au cas d'utilisation sont respectées. value peut être vide.

Les fixateurs de cette classe suppriment automatiquement les espaces blancs de début et de fin de la valeur, car ils doivent être ignorés lors du traitement de la valeur.

Combinaison de valeurs

La plupart des valeurs d'en-tête HTTP peuvent être combinées à l'aide d'une simple virgule ',' et d'un espace facultatif, et la signification sémantique est préservée. À titre d'exemple, ces deux-là devraient être sémantiquement similaires :

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

Il existe toutefois une exception notable à cette règle : Set-Cookie. En raison de cette exception et de la possibilité de cas d'utilisation personnalisés, QHttpHeaders ne combine pas automatiquement les valeurs.

Performances

La plupart des fonctions de QHttpHeaders fournissent des surcharges QHttpHeaders::WellKnownHeader et QAnyStringView. Du point de vue de l'utilisation de la mémoire et des calculs, il est recommandé d'utiliser les surcharges QHttpHeaders::WellKnownHeader.

Documentation sur les types de membres

enum class QHttpHeaders::WellKnownHeader

Liste d'en-têtes bien connus selon le registre de l'IANA.

ConstanteValeur
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

Fonction membre Documentation

[noexcept] QHttpHeaders::QHttpHeaders()

Crée un nouvel objet QHttpHeaders.

QHttpHeaders::QHttpHeaders(const QHttpHeaders &other)

Crée une copie de other.

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

Move-construit l'objet à partir de other, qui sera laissé à empty.

[noexcept] QHttpHeaders::~QHttpHeaders()

Se débarrasse de l'objet "headers".

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

Ajoute une entrée d'en-tête avec name et value et renvoie true en cas de succès.

Voir aussi append(QHttpHeaders::WellKnownHeader, QAnyStringView) et Allowed field name and value characters.

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

Cette fonction surcharge QHttpHeaders::append(QAnyStringView, QAnyStringView).

void QHttpHeaders::clear()

Efface toutes les entrées d'en-tête.

Voir aussi size().

QByteArray QHttpHeaders::combinedValue(QAnyStringView name) const

Renvoie les valeurs de l'en-tête name dans une chaîne de caractères combinée par des virgules. Renvoie une adresse null QByteArray si l'en-tête name n'existe pas.

Remarque : l'accès aux valeurs de l'en-tête "Set-Cookie" de cette manière peut ne pas fonctionner comme prévu. Il s'agit d'une exception notable dans la RFC HTTP en ce sens que ses valeurs ne peuvent pas être combinées de cette manière. Préférez values() à la place.

Voir aussi values(QAnyStringView).

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

Cette fonction surcharge QHttpHeaders::combinedValue(QAnyStringView).

bool QHttpHeaders::contains(QAnyStringView name) const

Retourne si les en-têtes contiennent un en-tête avec name.

Voir aussi contains(QHttpHeaders::WellKnownHeader).

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

Cette fonction surcharge QHttpHeaders::has(QAnyStringView).

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

Convertit la première valeur d'en-tête trouvée de name en un objet QDateTime, en respectant les formats de date HTTP standard. Si l'en-tête n'existe pas ou contient un QDateTime invalide, elle renvoie std::nullopt.

Cette fonction a été introduite dans Qt 6.10.

Voir aussi setDateTimeValue(), dateTimeValues(QAnyStringView name), et dateTimeValueAt(qsizetype i).

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

Cette fonction surcharge QHttpHeaders::dateTimeValue(QAnyStringView).

Cette fonction a été introduite dans Qt 6.10.

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

Convertit la valeur de l'en-tête à l'index i en un objet QDateTime en respectant les formats de date HTTP standard. L'index i doit être valide.

Cette fonction a été introduite dans Qt 6.10.

Voir aussi dateTimeValue(QAnyStringView name) et dateTimeValues(QAnyStringView name).

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

Renvoie toutes les valeurs d'en-tête de name dans une liste d'objets QDateTime, en respectant les formats de date HTTP standard. Si aucune valeur de date et d'heure valide n'est trouvée, elle renvoie std::nullopt.

Cette fonction a été introduite dans Qt 6.10.

Voir aussi dateTimeValue(QAnyStringView name) et dateTimeValueAt(qsizetype i).

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

Cette fonction surcharge QHttpHeaders::dateTimeValues(QAnyStringView).

Cette fonction a été introduite dans Qt 6.10.

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

Crée un nouvel objet QHttpHeaders qui est alimenté par headers.

Voir aussi Allowed field name and value characters.

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

Crée un nouvel objet QHttpHeaders qui est alimenté par headers.

Voir aussi Allowed field name and value characters.

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

Crée un nouvel objet QHttpHeaders qui est alimenté par headers.

Voir aussi Allowed field name and value characters.

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

Insère une entrée d'en-tête à l'index i, avec name et value. L'index doit être valide (voir size()). Retourne si l'insertion a réussi.

Voir aussi append(), insert(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size(), et Allowed field name and value characters.

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

Cette fonction surcharge QHttpHeaders::insert(qsizetype, QAnyStringView, QAnyStringView).

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

Renvoie la valeur du premier en-tête valide name interprété comme un entier de 64 bits. Si l'en-tête n'existe pas ou ne peut être interprété comme un entier, la fonction renvoie std::nullopt.

Cette fonction a été introduite dans Qt 6.10.

Voir aussi intValues(QAnyStringView name) et intValueAt(qsizetype i).

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

Cette fonction surcharge QHttpHeaders::intValue(QAnyStringView).

Cette fonction a été introduite dans Qt 6.10.

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

Renvoie la valeur de l'en-tête interprétée comme un entier de 64 bits à l'index i. L'index i doit être valide.

Cette fonction a été introduite dans Qt 6.10.

Voir aussi intValues(QAnyStringView name) et intValue(QAnyStringView name).

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

Renvoie les valeurs de l'en-tête name interprétées comme des entiers de 64 bits dans une liste. Si l'en-tête n'existe pas ou ne peut être interprété comme un entier, la fonction renvoie std::nullopt.

Cette fonction a été introduite dans Qt 6.10.

Voir aussi intValue(QAnyStringView name) et intValueAt(qsizetype i).

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

Cette fonction surcharge QHttpHeaders::intValues(QAnyStringView).

Cette fonction a été introduite dans Qt 6.10.

[noexcept] bool QHttpHeaders::isEmpty() const

Renvoie true si les en-têtes ont une taille de 0 ; sinon, renvoie false.

Voir aussi size().

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

Renvoie le nom de l'en-tête à l'index i. L'index i doit être valide (voir size()).

Les noms d'en-tête ne sont pas sensibles à la casse et les noms retournés sont en minuscules.

Voir aussi size() et valueAt().

void QHttpHeaders::removeAll(QAnyStringView name)

Supprime l'en-tête name.

Voir aussi removeAt() et removeAll(QHttpHeaders::WellKnownHeader).

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

Cette fonction surcharge QHttpHeaders::removeAll(QAnyStringView).

void QHttpHeaders::removeAt(qsizetype i)

Supprime l'en-tête à l'index i. L'index i doit être valide (voir size()).

Voir aussi removeAll(QHttpHeaders::WellKnownHeader), removeAll(QAnyStringView) et size().

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

Remplace l'entrée de l'en-tête à l'index i, par name et newValue. L'index doit être valide (voir size()). Retourne si le remplacement a réussi.

Voir aussi append(), replace(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size(), et Allowed field name and value characters.

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

Cette fonction surcharge QHttpHeaders::replace(qsizetype, QAnyStringView, QAnyStringView).

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

Si QHttpHeaders contient déjà name, remplace sa valeur par newValue et supprime les éventuelles entrées name supplémentaires. Si name n'existait pas, il ajoute une nouvelle entrée. Retourne true en cas de succès.

Cette fonction est une méthode pratique pour définir un en-tête unique name: newValue. Pour la plupart des en-têtes, l'ordre relatif n'a pas d'importance, ce qui permet de réutiliser une entrée existante s'il y en a une.

Cette fonction a été introduite dans Qt 6.8.

Voir aussi replaceOrAppend(QAnyStringView, QAnyStringView).

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

Cette fonction surcharge QHttpHeaders::replaceOrAppend(WellKnownHeader, QAnyStringView).

void QHttpHeaders::reserve(qsizetype size)

Tente d'allouer de la mémoire pour au moins size entrées d'en-tête.

Si vous connaissez à l'avance le nombre d'entrées d'en-tête, vous pouvez appeler cette fonction pour éviter les réallocations et la fragmentation de la mémoire.

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

Définit la valeur du nom de l'en-tête name en dateTime, selon le format standard HTTP IMF-fixdate. Si l'en-tête n'existe pas, il en ajoute un nouveau.

Cette fonction a été introduite dans Qt 6.10.

Voir aussi dateTimeValue(QAnyStringView name) et dateTimeValueAt(qsizetype i).

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

Cette fonction surcharge QHttpHeaders::setDateTimeValue(QAnyStringView).

Cette fonction a été introduite dans Qt 6.10.

[noexcept] qsizetype QHttpHeaders::size() const

Renvoie le nombre d'entrées d'en-tête.

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

Remplace ce site QHttpHeaders par other. Cette opération est très rapide et n'échoue jamais.

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

Renvoie les entrées d'en-tête sous la forme d'une liste de paires (nom, valeur). Les noms d'en-tête sont insensibles à la casse et les noms renvoyés sont en minuscules.

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

Renvoie les entrées de l'en-tête sous la forme d'un hachage du nom à la (aux) valeur(s). Les noms des en-têtes sont insensibles à la casse et les noms retournés sont en minuscules.

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

Renvoie les entrées de l'en-tête sous la forme d'une carte de noms à valeurs. Les noms des en-têtes sont insensibles à la casse et les noms retournés sont en minuscules.

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

Renvoie la valeur du (premier) en-tête name, ou defaultValue s'il n'existe pas.

Voir aussi value(QHttpHeaders::WellKnownHeader, QByteArrayView).

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

Cette fonction surcharge QHttpHeaders::value(QAnyStringView, QByteArrayView).

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

Renvoie la valeur de l'en-tête à l'index i. L'index i doit être valide (voir size()).

Voir aussi size(), value(), values(), combinedValue() et nameAt().

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

Renvoie les valeurs de l'en-tête name dans une liste. Retourne une liste vide si l'en-tête name n'existe pas.

Voir aussi values(QHttpHeaders::WellKnownHeader).

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

Cette fonction surcharge QHttpHeaders::values(QAnyStringView).

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

Renvoie un nom d'en-tête correspondant à l'adresse name fournie sous forme de vue.

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

Move-assigne other et renvoie une référence à cet objet.

other sera laissé à empty.

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

Affecte le contenu de other et renvoie une référence à cet objet.

Non-membres apparentés

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

Écrit headers dans le flux debug.

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