En esta página

QHttpHeaders Class

QHttpHeaders es una clase para contener cabeceras HTTP. Más...

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

Tipos Públicos

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

Funciones Públicas

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)

Miembros públicos estáticos

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)

Descripción detallada

La clase es un tipo de interfaz para las APIs de red Qt que utilizan o consumen dichas cabeceras.

Caracteres de nombre y valor de campo permitidos

Una cabecera HTTP consta de nombre y valor. Al establecerlos, QHttpHeaders valida que name y value sólo contengan caracteres permitidos por las RFC de HTTP. Para obtener información detallada, consulte los capítulos 5.1 y 5.5 de RFC 9110.

En total, esto significa que

  • name debe constar de caracteres ASCII visibles, y no debe estar vacío
  • value puede constar de bytes arbitrarios, siempre que se respeten las reglas de codificación específicas de la cabecera y del caso de uso. value puede estar vacío

Los definidores de esta clase eliminan automáticamente cualquier espacio en blanco inicial o final del valor, ya que deben ignorarse durante el procesamiento del valor.

Combinación de valores

La mayoría de los valores de cabecera HTTP pueden combinarse con una sola coma ',' más un espacio en blanco opcional, y se conserva el significado semántico. A modo de ejemplo, estos dos valores deberían ser semánticamente similares:

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

Sin embargo, existe una notable excepción a esta regla: Set-Cookie. Debido a esto y a la posibilidad de casos de uso personalizados, QHttpHeaders no combina automáticamente los valores.

Rendimiento

La mayoría de las funciones de QHttpHeaders ofrecen sobrecargas tanto en QHttpHeaders::WellKnownHeader como en QAnyStringView. Desde el punto de vista del uso de memoria y del cálculo, se recomienda utilizar las sobrecargas de QHttpHeaders::WellKnownHeader.

Documentación de tipos de miembros

enum class QHttpHeaders::WellKnownHeader

Lista de cabeceras conocidas según el registro IANA.

ConstanteValor
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

Documentación de la función de miembro

[noexcept] QHttpHeaders::QHttpHeaders()

Crea un nuevo objeto QHttpHeaders.

QHttpHeaders::QHttpHeaders(const QHttpHeaders &other)

Crea una copia de other.

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

Mover-construye el objeto a partir de other, que quedará empty.

[noexcept] QHttpHeaders::~QHttpHeaders()

Elimina el objeto headers.

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

Añade una entrada de cabecera con name y value y devuelve true si tiene éxito.

Véase también append(QHttpHeaders::WellKnownHeader, QAnyStringView) y Allowed field name and value characters.

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

Esta función sobrecarga QHttpHeaders::append(QAnyStringView, QAnyStringView).

void QHttpHeaders::clear()

Borra todas las entradas de la cabecera.

Véase también size().

QByteArray QHttpHeaders::combinedValue(QAnyStringView name) const

Devuelve los valores de la cabecera name en una cadena combinada por comas. Devuelve un null QByteArray si la cabecera con name no existe.

Nota: Acceder a los valores de la cabecera 'Set-Cookie' de esta forma puede no funcionar como se pretende. Es una excepción notable en la RFC HTTP en el sentido de que sus valores no pueden combinarse de esta forma. Prefiera values() en su lugar.

Ver también values(QAnyStringView).

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

Esta función sobrecarga QHttpHeaders::combinedValue(QAnyStringView).

bool QHttpHeaders::contains(QAnyStringView name) const

Devuelve si las cabeceras contienen cabecera con name.

Véase también contains(QHttpHeaders::WellKnownHeader).

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

Esta función sobrecarga QHttpHeaders::has(QAnyStringView).

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

Convierte el primer valor de cabecera encontrado de name en un objeto QDateTime, siguiendo los formatos de fecha HTTP estándar. Si la cabecera no existe o contiene un QDateTime no válido , devuelve std::nullopt.

Esta función se introdujo en Qt 6.10.

Ver también setDateTimeValue(), dateTimeValues(QAnyStringView nombre), y dateTimeValueAt(qsizetype i).

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

Esta función sobrecarga QHttpHeaders::dateTimeValue(QAnyStringView).

Esta función se introdujo en Qt 6.10.

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

Convierte el valor del encabezado en el índice i a un objeto QDateTime siguiendo los formatos de fecha HTTP estándar. El índice i debe ser válido.

Esta función se introdujo en Qt 6.10.

Ver también dateTimeValue(QAnyStringView nombre) y dateTimeValues(QAnyStringView nombre).

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

Devuelve todos los valores de cabecera de name en una lista de objetos QDateTime, siguiendo los formatos de fecha HTTP estándar. Si no se encuentran valores de fecha-hora válidos, devuelve std::nullopt.

Esta función se introdujo en Qt 6.10.

Ver también dateTimeValue(QAnyStringView name) y dateTimeValueAt(qsizetype i).

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

Esta función sobrecarga QHttpHeaders::dateTimeValues(QAnyStringView).

Esta función se introdujo en Qt 6.10.

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

Crea un nuevo objeto QHttpHeaders que se rellena con headers.

Véase también Allowed field name and value characters.

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

Crea un nuevo objeto QHttpHeaders que se rellena con headers.

Véase también Allowed field name and value characters.

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

Crea un nuevo objeto QHttpHeaders que se rellena con headers.

Véase también Allowed field name and value characters.

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

Inserta una entrada de cabecera en el índice i, con name y value. El índice debe ser válido (véase size()). Devuelve si la inserción se ha realizado correctamente.

Véase también append(), insert(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size() y Allowed field name and value characters.

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

Esta función sobrecarga QHttpHeaders::insert(qsizetype, QAnyStringView, QAnyStringView).

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

Devuelve el valor de la primera cabecera válida name interpretada como un entero de 64 bits. Si la cabecera no existe o no puede ser interpretada como un entero, devuelve std::nullopt.

Esta función se introdujo en Qt 6.10.

Véase también intValues(QAnyStringView name) y intValueAt(qsizetype i).

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

Esta función sobrecarga QHttpHeaders::intValue(QAnyStringView).

Esta función se introdujo en Qt 6.10.

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

Devuelve el valor de cabecera interpretado como entero de 64 bits en el índice i. El índice i debe ser válido.

Esta función se introdujo en Qt 6.10.

Ver también intValues(QAnyStringView nombre) y intValue(QAnyStringView nombre).

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

Devuelve los valores de la cabecera name interpretados como enteros de 64 bits en una lista. Si la cabecera no existe o no puede ser interpretada como un entero, devuelve std::nullopt.

Esta función se introdujo en Qt 6.10.

Véase también intValue(QAnyStringView name) y intValueAt(qsizetype i).

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

Esta función sobrecarga QHttpHeaders::intValues(QAnyStringView).

Esta función se introdujo en Qt 6.10.

[noexcept] bool QHttpHeaders::isEmpty() const

Devuelve true si las cabeceras tienen tamaño 0; en caso contrario devuelve false.

Véase también size().

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

Devuelve el nombre de la cabecera en el índice i. El índice i debe ser válido (véase size()).

Los nombres de cabecera no distinguen entre mayúsculas y minúsculas, y los nombres devueltos se escriben en minúsculas.

Véase también size() y valueAt().

void QHttpHeaders::removeAll(QAnyStringView name)

Elimina el encabezado name.

Véase también removeAt() y removeAll(QHttpHeaders::WellKnownHeader).

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

Esta función sobrecarga QHttpHeaders::removeAll(QAnyStringView).

void QHttpHeaders::removeAt(qsizetype i)

Elimina la cabecera en el índice i. El índice i debe ser válido (véase size()).

Ver también removeAll(QHttpHeaders::WellKnownHeader), removeAll(QAnyStringView), y size().

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

Sustituye la entrada de la cabecera en el índice i, por name y newValue. El índice debe ser válido (véase size()). Devuelve si la sustitución se ha realizado correctamente.

Ver también append(), replace(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size(), y Allowed field name and value characters.

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

Esta función sobrecarga QHttpHeaders::replace(qsizetype, QAnyStringView, QAnyStringView).

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

Si QHttpHeaders ya contiene name, sustituye su valor por newValue y elimina posibles entradas adicionales de name. Si name no existía, añade una nueva entrada. Devuelve true si tiene éxito.

Esta función es un método práctico para establecer una única cabecera name: newValue. Para la mayoría de las cabeceras el orden relativo no importa, lo que permite reutilizar una entrada existente si existe.

Esta función se introdujo en Qt 6.8.

Ver también replaceOrAppend(QAnyStringView, QAnyStringView).

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

Esta función sobrecarga QHttpHeaders::replaceOrAppend(WellKnownHeader, QAnyStringView).

void QHttpHeaders::reserve(qsizetype size)

Intenta asignar memoria para al menos size entradas de cabecera.

Si sabe de antemano cuántas entradas de cabecera habrá, puede llamar a esta función para evitar reasignaciones y fragmentación de memoria.

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

Establece el valor del nombre de la cabecera name a dateTime, siguiendo el formato estándar HTTP IMF-fixdate. Si la cabecera no existe, añade una nueva.

Esta función se introdujo en Qt 6.10.

Ver también dateTimeValue(QAnyStringView name) y dateTimeValueAt(qsizetype i).

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

Esta función sobrecarga QHttpHeaders::setDateTimeValue(QAnyStringView).

Esta función se introdujo en Qt 6.10.

[noexcept] qsizetype QHttpHeaders::size() const

Devuelve el número de entradas de cabecera.

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

Cambia este QHttpHeaders por other. Esta operación es muy rápida y nunca falla.

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

Devuelve las entradas de cabecera como una lista de pares (nombre, valor). Los nombres de cabecera no distinguen entre mayúsculas y minúsculas, y los nombres devueltos están en minúsculas.

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

Devuelve las entradas de cabecera como un hash de nombre a valor(es). Los nombres de cabecera no distinguen entre mayúsculas y minúsculas, y los nombres devueltos están en minúsculas.

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

Devuelve las entradas de encabezado como un mapa de nombre a valor(es). Los nombres de cabecera no distinguen entre mayúsculas y minúsculas, y los nombres devueltos se escriben en minúsculas.

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

Devuelve el valor de la (primera) cabecera name, o defaultValue si no existe.

Véase también value(QHttpHeaders::WellKnownHeader, QByteArrayView).

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

Esta función sobrecarga QHttpHeaders::value(QAnyStringView, QByteArrayView).

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

Devuelve el valor de la cabecera en el índice i. El índice i debe ser válido (véase size()).

Véase también size(), value(), values(), combinedValue() y nameAt().

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

Devuelve los valores de la cabecera name en una lista. Devuelve una lista vacía si la cabecera con name no existe.

Ver también values(QHttpHeaders::WellKnownHeader).

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

Esta función sobrecarga QHttpHeaders::values(QAnyStringView).

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

Devuelve un nombre de cabecera correspondiente a la name proporcionada como vista.

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

Move-asigna other y devuelve una referencia a este objeto.

other se dejará empty.

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

Asigna el contenido de other y devuelve una referencia a este objeto.

No miembros relacionados

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

Escribe headers en el flujo 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.