Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QHttpHeaders Class Reference

#include <qhttpheaders.h>

+ Collaboration diagram for QHttpHeaders:

Public Types

enum class  WellKnownHeader {
  AIM , Accept , AcceptAdditions , AcceptCH ,
  AcceptDatetime , AcceptEncoding , AcceptFeatures , AcceptLanguage ,
  AcceptPatch , AcceptPost , AcceptRanges , AcceptSignature ,
  AccessControlAllowCredentials , AccessControlAllowHeaders , AccessControlAllowMethods , AccessControlAllowOrigin ,
  AccessControlExposeHeaders , AccessControlMaxAge , AccessControlRequestHeaders , AccessControlRequestMethod ,
  Age , Allow , ALPN , AltSvc ,
  AltUsed , Alternates , ApplyToRedirectRef , AuthenticationControl ,
  AuthenticationInfo , Authorization , CacheControl , CacheStatus ,
  CalManagedID , CalDAVTimezones , CapsuleProtocol , CDNCacheControl ,
  CDNLoop , CertNotAfter , CertNotBefore , ClearSiteData ,
  ClientCert , ClientCertChain , Close , Connection ,
  ContentDigest , ContentDisposition , ContentEncoding , ContentID ,
  ContentLanguage , ContentLength , ContentLocation , ContentRange ,
  ContentSecurityPolicy , ContentSecurityPolicyReportOnly , ContentType , Cookie ,
  CrossOriginEmbedderPolicy , CrossOriginEmbedderPolicyReportOnly , CrossOriginOpenerPolicy , CrossOriginOpenerPolicyReportOnly ,
  CrossOriginResourcePolicy , DASL , Date , DAV ,
  DeltaBase , Depth , Destination , DifferentialID ,
  DPoP , DPoPNonce , EarlyData , ETag ,
  Expect , ExpectCT , Expires , Forwarded ,
  From , Hobareg , Host , If ,
  IfMatch , IfModifiedSince , IfNoneMatch , IfRange ,
  IfScheduleTagMatch , IfUnmodifiedSince , IM , IncludeReferredTokenBindingID ,
  KeepAlive , Label , LastEventID , LastModified ,
  Link , Location , LockToken , MaxForwards ,
  MementoDatetime , Meter , MIMEVersion , Negotiate ,
  NEL , ODataEntityId , ODataIsolation , ODataMaxVersion ,
  ODataVersion , OptionalWWWAuthenticate , OrderingType , Origin ,
  OriginAgentCluster , OSCORE , OSLCCoreVersion , Overwrite ,
  PingFrom , PingTo , Position , Prefer ,
  PreferenceApplied , Priority , ProxyAuthenticate , ProxyAuthenticationInfo ,
  ProxyAuthorization , ProxyStatus , PublicKeyPins , PublicKeyPinsReportOnly ,
  Range , RedirectRef , Referer , Refresh ,
  ReplayNonce , ReprDigest , RetryAfter , ScheduleReply ,
  ScheduleTag , SecPurpose , SecTokenBinding , SecWebSocketAccept ,
  SecWebSocketExtensions , SecWebSocketKey , SecWebSocketProtocol , SecWebSocketVersion ,
  Server , ServerTiming , SetCookie , Signature ,
  SignatureInput , SLUG , SoapAction , StatusURI ,
  StrictTransportSecurity , Sunset , SurrogateCapability , SurrogateControl ,
  TCN , TE , Timeout , Topic ,
  Traceparent , Tracestate , Trailer , TransferEncoding ,
  TTL , Upgrade , Urgency , UserAgent ,
  VariantVary , Vary , Via , WantContentDigest ,
  WantReprDigest , WWWAuthenticate , XContentTypeOptions , XFrameOptions ,
  AcceptCharset , CPEPInfo , Pragma , ProtocolInfo ,
  ProtocolQuery
}
 List of well known headers as per \l {https://www.iana.org/assignments/http-fields}{IANA registry}. More...
 

Public Member Functions

Q_NETWORK_EXPORT QHttpHeaders () noexcept
 Creates a new QHttpHeaders object.
 
Q_NETWORK_EXPORT ~QHttpHeaders ()
 Disposes of the headers object.
 
Q_NETWORK_EXPORT QHttpHeaders (const QHttpHeaders &other)
 Creates a copy of other.
 
 QHttpHeaders (QHttpHeaders &&other) noexcept=default
 Move-constructs the object from other, which will be left \l{isEmpty()}{empty}.
 
Q_NETWORK_EXPORT QHttpHeadersoperator= (const QHttpHeaders &other)
 Assigns the contents of other and returns a reference to this object.
 
void swap (QHttpHeaders &other) noexcept
 Swaps this QHttpHeaders with other.
 
Q_NETWORK_EXPORT bool append (QAnyStringView name, QAnyStringView value)
 Appends a header entry with name and value and returns true if successful.
 
Q_NETWORK_EXPORT bool append (WellKnownHeader name, QAnyStringView value)
 
Q_NETWORK_EXPORT bool insert (qsizetype i, QAnyStringView name, QAnyStringView value)
 Inserts a header entry at index i, with name and value.
 
Q_NETWORK_EXPORT bool insert (qsizetype i, WellKnownHeader name, QAnyStringView value)
 
Q_NETWORK_EXPORT bool replace (qsizetype i, QAnyStringView name, QAnyStringView newValue)
 Replaces the header entry at index i, with name and newValue.
 
Q_NETWORK_EXPORT bool replace (qsizetype i, WellKnownHeader name, QAnyStringView newValue)
 
Q_NETWORK_EXPORT bool replaceOrAppend (QAnyStringView name, QAnyStringView newValue)
 
Q_NETWORK_EXPORT bool replaceOrAppend (WellKnownHeader name, QAnyStringView newValue)
 
Q_NETWORK_EXPORT bool contains (QAnyStringView name) const
 Returns whether the headers contain header with name.
 
Q_NETWORK_EXPORT bool contains (WellKnownHeader name) const
 
Q_NETWORK_EXPORT void clear ()
 Clears all header entries.
 
Q_NETWORK_EXPORT void removeAll (QAnyStringView name)
 Removes the header name.
 
Q_NETWORK_EXPORT void removeAll (WellKnownHeader name)
 
Q_NETWORK_EXPORT void removeAt (qsizetype i)
 Removes the header at index i.
 
Q_NETWORK_EXPORT QByteArrayView value (QAnyStringView name, QByteArrayView defaultValue={}) const noexcept
 Returns the value of the (first) header name, or defaultValue if it doesn't exist.
 
Q_NETWORK_EXPORT QByteArrayView value (WellKnownHeader name, QByteArrayView defaultValue={}) const noexcept
 
Q_NETWORK_EXPORT QList< QByteArrayvalues (QAnyStringView name) const
 Returns the values of header name in a list.
 
Q_NETWORK_EXPORT QList< QByteArrayvalues (WellKnownHeader name) const
 
Q_NETWORK_EXPORT QByteArrayView valueAt (qsizetype i) const noexcept
 Returns the header value at index i.
 
Q_NETWORK_EXPORT QLatin1StringView nameAt (qsizetype i) const noexcept
 Returns the header name at index i.
 
Q_NETWORK_EXPORT QByteArray combinedValue (QAnyStringView name) const
 Returns the values of header name in a comma-combined string.
 
Q_NETWORK_EXPORT QByteArray combinedValue (WellKnownHeader name) const
 
Q_NETWORK_EXPORT qsizetype size () const noexcept
 Returns the number of header entries.
 
Q_NETWORK_EXPORT void reserve (qsizetype size)
 Attempts to allocate memory for at least size header entries.
 
bool isEmpty () const noexcept
 Returns true if the headers have size 0; otherwise returns false.
 
Q_NETWORK_EXPORT QList< std::pair< QByteArray, QByteArray > > toListOfPairs () const
 Returns the header entries as a list of (name, value) pairs.
 
Q_NETWORK_EXPORT QMultiMap< QByteArray, QByteArraytoMultiMap () const
 Returns the header entries as a map from name to value(s).
 
Q_NETWORK_EXPORT QMultiHash< QByteArray, QByteArraytoMultiHash () const
 Returns the header entries as a hash from name to value(s).
 

Static Public Member Functions

static Q_NETWORK_EXPORT QByteArrayView wellKnownHeaderName (WellKnownHeader name) noexcept
 Returns a header name corresponding to the provided name as a view.
 
static Q_NETWORK_EXPORT QHttpHeaders fromListOfPairs (const QList< std::pair< QByteArray, QByteArray > > &headers)
 Creates a new QHttpHeaders object that is populated with headers.
 
static Q_NETWORK_EXPORT QHttpHeaders fromMultiMap (const QMultiMap< QByteArray, QByteArray > &headers)
 Creates a new QHttpHeaders object that is populated with headers.
 
static Q_NETWORK_EXPORT QHttpHeaders fromMultiHash (const QMultiHash< QByteArray, QByteArray > &headers)
 Creates a new QHttpHeaders object that is populated with headers.
 

Friends

Q_NETWORK_EXPORT QDebug operator<< (QDebug debug, const QHttpHeaders &headers)
 Writes headers into debug stream.
 

Detailed Description

Definition at line 18 of file qhttpheaders.h.

Member Enumeration Documentation

◆ WellKnownHeader

enum class QHttpHeaders::WellKnownHeader
strong

List of well known headers as per \l {https://www.iana.org/assignments/http-fields}{IANA registry}.

\value AIM \value Accept \value AcceptAdditions \value AcceptCH \value AcceptDatetime \value AcceptEncoding \value AcceptFeatures \value AcceptLanguage \value AcceptPatch \value AcceptPost \value AcceptRanges \value AcceptSignature \value AccessControlAllowCredentials \value AccessControlAllowHeaders \value AccessControlAllowMethods \value AccessControlAllowOrigin \value AccessControlExposeHeaders \value AccessControlMaxAge \value AccessControlRequestHeaders \value AccessControlRequestMethod \value Age \value Allow \value ALPN \value AltSvc \value AltUsed \value Alternates \value ApplyToRedirectRef \value AuthenticationControl \value AuthenticationInfo \value Authorization \value CacheControl \value CacheStatus \value CalManagedID \value CalDAVTimezones \value CapsuleProtocol \value CDNCacheControl \value CDNLoop \value CertNotAfter \value CertNotBefore \value ClearSiteData \value ClientCert \value ClientCertChain \value Close \value Connection \value ContentDigest \value ContentDisposition \value ContentEncoding \value ContentID \value ContentLanguage \value ContentLength \value ContentLocation \value ContentRange \value ContentSecurityPolicy \value ContentSecurityPolicyReportOnly \value ContentType \value Cookie \value CrossOriginEmbedderPolicy \value CrossOriginEmbedderPolicyReportOnly \value CrossOriginOpenerPolicy \value CrossOriginOpenerPolicyReportOnly \value CrossOriginResourcePolicy \value DASL \value Date \value DAV \value DeltaBase \value Depth \value Destination \value DifferentialID \value DPoP \value DPoPNonce \value EarlyData \value ETag \value Expect \value ExpectCT \value Expires \value Forwarded \value From \value Hobareg \value Host \value If \value IfMatch \value IfModifiedSince \value IfNoneMatch \value IfRange \value IfScheduleTagMatch \value IfUnmodifiedSince \value IM \value IncludeReferredTokenBindingID \value KeepAlive \value Label \value LastEventID \value LastModified \value Link \value Location \value LockToken \value MaxForwards \value MementoDatetime \value Meter \value MIMEVersion \value Negotiate \value NEL \value ODataEntityId \value ODataIsolation \value ODataMaxVersion \value ODataVersion \value OptionalWWWAuthenticate \value OrderingType \value Origin \value OriginAgentCluster \value OSCORE \value OSLCCoreVersion \value Overwrite \value PingFrom \value PingTo \value Position \value Prefer \value PreferenceApplied \value Priority \value ProxyAuthenticate \value ProxyAuthenticationInfo \value ProxyAuthorization \value ProxyStatus \value PublicKeyPins \value PublicKeyPinsReportOnly \value Range \value RedirectRef \value Referer \value Refresh \value ReplayNonce \value ReprDigest \value RetryAfter \value ScheduleReply \value ScheduleTag \value SecPurpose \value SecTokenBinding \value SecWebSocketAccept \value SecWebSocketExtensions \value SecWebSocketKey \value SecWebSocketProtocol \value SecWebSocketVersion \value Server \value ServerTiming \value SetCookie \value Signature \value SignatureInput \value SLUG \value SoapAction \value StatusURI \value StrictTransportSecurity \value Sunset \value SurrogateCapability \value SurrogateControl \value TCN \value TE \value Timeout \value Topic \value Traceparent \value Tracestate \value Trailer \value TransferEncoding \value TTL \value Upgrade \value Urgency \value UserAgent \value VariantVary \value Vary \value Via \value WantContentDigest \value WantReprDigest \value WWWAuthenticate \value XContentTypeOptions \value XFrameOptions \value AcceptCharset \value CPEPInfo \value Pragma \value ProtocolInfo \value ProtocolQuery

Enumerator
AIM 
Accept 
AcceptAdditions 
AcceptCH 
AcceptDatetime 
AcceptEncoding 
AcceptFeatures 
AcceptLanguage 
AcceptPatch 
AcceptPost 
AcceptRanges 
AcceptSignature 
AccessControlAllowCredentials 
AccessControlAllowHeaders 
AccessControlAllowMethods 
AccessControlAllowOrigin 
AccessControlExposeHeaders 
AccessControlMaxAge 
AccessControlRequestHeaders 
AccessControlRequestMethod 
Age 
Allow 
ALPN 
AltSvc 
AltUsed 
Alternates 
ApplyToRedirectRef 
AuthenticationControl 
AuthenticationInfo 
Authorization 
CacheControl 
CacheStatus 
CalManagedID 
CalDAVTimezones 
CapsuleProtocol 
CDNCacheControl 
CDNLoop 
CertNotAfter 
CertNotBefore 
ClearSiteData 
ClientCert 
ClientCertChain 
Close 
Connection 
ContentDigest 
ContentDisposition 
ContentEncoding 
ContentID 
ContentLanguage 
ContentLength 
ContentLocation 
ContentRange 
ContentSecurityPolicy 
ContentSecurityPolicyReportOnly 
ContentType 
Cookie 
CrossOriginEmbedderPolicy 
CrossOriginEmbedderPolicyReportOnly 
CrossOriginOpenerPolicy 
CrossOriginOpenerPolicyReportOnly 
CrossOriginResourcePolicy 
DASL 
Date 
DAV 
DeltaBase 
Depth 
Destination 
DifferentialID 
DPoP 
DPoPNonce 
EarlyData 
ETag 
Expect 
ExpectCT 
Expires 
Forwarded 
From 
Hobareg 
Host 
If 
IfMatch 
IfModifiedSince 
IfNoneMatch 
IfRange 
IfScheduleTagMatch 
IfUnmodifiedSince 
IM 
IncludeReferredTokenBindingID 
KeepAlive 
Label 
LastEventID 
LastModified 
Link 
Location 
LockToken 
MaxForwards 
MementoDatetime 
Meter 
MIMEVersion 
Negotiate 
NEL 
ODataEntityId 
ODataIsolation 
ODataMaxVersion 
ODataVersion 
OptionalWWWAuthenticate 
OrderingType 
Origin 
OriginAgentCluster 
OSCORE 
OSLCCoreVersion 
Overwrite 
PingFrom 
PingTo 
Position 
Prefer 
PreferenceApplied 
Priority 
ProxyAuthenticate 
ProxyAuthenticationInfo 
ProxyAuthorization 
ProxyStatus 
PublicKeyPins 
PublicKeyPinsReportOnly 
Range 
RedirectRef 
Referer 
Refresh 
ReplayNonce 
ReprDigest 
RetryAfter 
ScheduleReply 
ScheduleTag 
SecPurpose 
SecTokenBinding 
SecWebSocketAccept 
SecWebSocketExtensions 
SecWebSocketKey 
SecWebSocketProtocol 
SecWebSocketVersion 
Server 
ServerTiming 
SetCookie 
Signature 
SignatureInput 
SLUG 
SoapAction 
StatusURI 
StrictTransportSecurity 
Sunset 
SurrogateCapability 
SurrogateControl 
TCN 
TE 
Timeout 
Topic 
Traceparent 
Tracestate 
Trailer 
TransferEncoding 
TTL 
Upgrade 
Urgency 
UserAgent 
VariantVary 
Vary 
Via 
WantContentDigest 
WantReprDigest 
WWWAuthenticate 
XContentTypeOptions 
XFrameOptions 
AcceptCharset 
CPEPInfo 
Pragma 
ProtocolInfo 
ProtocolQuery 

Definition at line 22 of file qhttpheaders.h.

Constructor & Destructor Documentation

◆ QHttpHeaders() [1/3]

QHttpHeaders::QHttpHeaders ( )
noexcept

Creates a new QHttpHeaders object.

Definition at line 876 of file qhttpheaders.cpp.

◆ ~QHttpHeaders()

QHttpHeaders::~QHttpHeaders ( )
default

Disposes of the headers object.

◆ QHttpHeaders() [2/3]

QHttpHeaders::QHttpHeaders ( const QHttpHeaders & other)
default

Creates a copy of other.

◆ QHttpHeaders() [3/3]

QHttpHeaders::QHttpHeaders ( QHttpHeaders && other)
defaultnoexcept

Move-constructs the object from other, which will be left \l{isEmpty()}{empty}.

Member Function Documentation

◆ append() [1/2]

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)
{Allowed field name and value characters}

Definition at line 1147 of file qhttpheaders.cpp.

References d, isValidHttpHeaderNameField(), isValidHttpHeaderValueField(), and normalizedValue().

Referenced by QHttpHeaderParser::appendHeaderField(), QNetworkAccessManager::createRequest(), QRestAccessManagerPrivate::executeRequest(), QNetworkHeadersPrivate::fromRawToHttp(), setFromRawHeader(), and QHttpHeaderParser::setHeaderField().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ append() [2/2]

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

Definition at line 1160 of file qhttpheaders.cpp.

References d, isValidHttpHeaderValueField(), and normalizedValue().

+ Here is the call graph for this function:

◆ clear()

void QHttpHeaders::clear ( )

Clears all header entries.

See also
size()

Definition at line 1543 of file qhttpheaders.cpp.

References d.

Referenced by QHttpHeaderParser::clear(), QNetworkRequestFactory::clearCommonHeaders(), QHttpHeaderParser::clearHeaders(), and QNetworkHeadersPrivate::clearHeaders().

+ Here is the caller graph for this function:

◆ combinedValue() [1/2]

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 \l {https://datatracker.ietf.org/doc/html/rfc9110#name-field-order}{HTTP RFC} in that its values cannot be combined this way. Prefer \l values() instead.
See also
values(QAnyStringView)

Definition at line 1432 of file qhttpheaders.cpp.

References d.

Referenced by QNetworkHeadersPrivate::rawHeader().

+ Here is the caller graph for this function:

◆ combinedValue() [2/2]

QByteArray QHttpHeaders::combinedValue ( WellKnownHeader name) const

Definition at line 1445 of file qhttpheaders.cpp.

References d.

◆ contains() [1/2]

bool QHttpHeaders::contains ( QAnyStringView name) const

Returns whether the headers contain header with name.

See also
contains(QHttpHeaders::WellKnownHeader)

Definition at line 1283 of file qhttpheaders.cpp.

References d, and headerNameMatches().

Referenced by QNetworkProxy::hasRawHeader(), QNetworkRequest::hasRawHeader(), QNetworkReplyWasmImplPrivate::headersReceived(), and QNetworkReplyHttpImplPrivate::replyDownloadMetaData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ contains() [2/2]

bool QHttpHeaders::contains ( WellKnownHeader name) const

Definition at line 1294 of file qhttpheaders.cpp.

References d, and headerNameMatches().

+ Here is the call graph for this function:

◆ fromListOfPairs()

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

Creates a new QHttpHeaders object that is populated with headers.

See also
{Allowed field name and value characters}

Definition at line 886 of file qhttpheaders.cpp.

References header(), and reserve().

+ Here is the call graph for this function:

◆ fromMultiHash()

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

Creates a new QHttpHeaders object that is populated with headers.

See also
{Allowed field name and value characters}

Definition at line 916 of file qhttpheaders.cpp.

References reserve().

+ Here is the call graph for this function:

◆ fromMultiMap()

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

Creates a new QHttpHeaders object that is populated with headers.

See also
{Allowed field name and value characters}

Definition at line 901 of file qhttpheaders.cpp.

References reserve().

+ Here is the call graph for this function:

◆ insert() [1/2]

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 \l size()). Returns whether the insert succeeded.

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

Definition at line 1178 of file qhttpheaders.cpp.

References d, i, isValidHttpHeaderNameField(), isValidHttpHeaderValueField(), and normalizedValue().

Referenced by QHttpHeaderParser::prependHeaderField().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert() [2/2]

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

Definition at line 1192 of file qhttpheaders.cpp.

References d, i, isValidHttpHeaderValueField(), and normalizedValue().

+ Here is the call graph for this function:

◆ isEmpty()

bool QHttpHeaders::isEmpty ( ) const
inlinenoexcept

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

See also
size()

Definition at line 248 of file qhttpheaders.h.

Referenced by QNetworkRequestFactory::clearCommonHeaders(), QNetworkHeadersPrivate::fromHttpToRaw(), QHttpHeaderParser::parseHeaders(), QNetworkHeadersPrivate::rawHeadersKeys(), and QCacheItem::read().

+ Here is the caller graph for this function:

◆ nameAt()

QLatin1StringView QHttpHeaders::nameAt ( qsizetype i) const
noexcept

Returns the header name at index i.

The index i must be valid (see \l size()).

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

See also
size(), valueAt()

Definition at line 1414 of file qhttpheaders.cpp.

References QLatin1StringView::at(), d, and i.

Referenced by QNetworkReplyHttpImplPrivate::fetchCacheMetaData(), QNetworkHeadersPrivate::fromHttpToRaw(), QHttpNetworkRequestPrivate::header(), QNetworkHeadersPrivate::rawHeader(), and QNetworkHeadersPrivate::rawHeadersKeys().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

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

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

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

other will be left \l{isEmpty()}{empty}.

◆ removeAll() [1/2]

void QHttpHeaders::removeAll ( QAnyStringView name)

Removes the header name.

See also
removeAt(), removeAll(QHttpHeaders::WellKnownHeader)

Definition at line 1307 of file qhttpheaders.cpp.

References d, and QHttpHeadersPrivate::removeAll().

Referenced by QHttpHeaderParser::removeHeaderField(), QNetworkHeadersPrivate::setCookedHeader(), and setFromRawHeader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAll() [2/2]

void QHttpHeaders::removeAll ( WellKnownHeader name)

Definition at line 1318 of file qhttpheaders.cpp.

References d, and QHttpHeadersPrivate::removeAll().

+ Here is the call graph for this function:

◆ removeAt()

void QHttpHeaders::removeAt ( qsizetype i)

Removes the header at index i.

The index i must be valid (see \l size()).

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

Definition at line 1333 of file qhttpheaders.cpp.

References d, and i.

◆ replace() [1/2]

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 \l size()). Returns whether the replace succeeded.

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

Definition at line 1212 of file qhttpheaders.cpp.

References d, i, isValidHttpHeaderNameField(), isValidHttpHeaderValueField(), and normalizedValue().

+ Here is the call graph for this function:

◆ replace() [2/2]

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

Definition at line 1226 of file qhttpheaders.cpp.

References d, i, isValidHttpHeaderValueField(), and normalizedValue().

+ Here is the call graph for this function:

◆ replaceOrAppend() [1/2]

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

Definition at line 1266 of file qhttpheaders.cpp.

References append(), d, isValidHttpHeaderNameField(), isValidHttpHeaderValueField(), normalizedValue(), and QHttpHeadersPrivate::replaceOrAppend().

Referenced by QHttpNetworkConnectionChannel::ensureConnection(), QNetworkRequestFactoryPrivate::newRequest(), and QNetworkHeadersPrivate::setHeader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replaceOrAppend() [2/2]

bool QHttpHeaders::replaceOrAppend ( WellKnownHeader name,
QAnyStringView newValue )
Since
6.8

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.

See also
replaceOrAppend(QAnyStringView, QAnyStringView)

Definition at line 1251 of file qhttpheaders.cpp.

References append(), d, isValidHttpHeaderValueField(), normalizedValue(), and QHttpHeadersPrivate::replaceOrAppend().

+ Here is the call graph for this function:

◆ reserve()

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.

Definition at line 1472 of file qhttpheaders.cpp.

References d.

Referenced by fromListOfPairs(), fromMultiHash(), fromMultiMap(), and QNetworkHeadersPrivate::fromRawToHttp().

+ Here is the caller graph for this function:

◆ size()

qsizetype QHttpHeaders::size ( ) const
noexcept

Returns the number of header entries.

Definition at line 1458 of file qhttpheaders.cpp.

References d.

Referenced by QNetworkHeadersPrivate::fromHttpToRaw(), QHttpNetworkRequestPrivate::header(), QNetworkReplyWasmImplPrivate::headersReceived(), QNetworkHeadersPrivate::rawHeader(), and QNetworkHeadersPrivate::rawHeadersKeys().

+ Here is the caller graph for this function:

◆ swap()

void QHttpHeaders::swap ( QHttpHeaders & other)
inlinenoexcept

Swaps this QHttpHeaders with other.

This function is very fast and never fails.

Definition at line 212 of file qhttpheaders.h.

References d, other(), and swap().

Referenced by swap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toListOfPairs()

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.

Definition at line 1498 of file qhttpheaders.cpp.

References QList< T >::append(), d, list, and QList< T >::reserve().

+ Here is the call graph for this function:

◆ toMultiHash()

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.

Definition at line 1527 of file qhttpheaders.cpp.

References d, and hash.

◆ toMultiMap()

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.

Definition at line 1513 of file qhttpheaders.cpp.

References d, QMap< Key, T >::insert(), and map.

+ Here is the call graph for this function:

◆ value() [1/2]

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

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

See also
value(QHttpHeaders::WellKnownHeader, QByteArrayView)

Definition at line 1346 of file qhttpheaders.cpp.

References d.

Referenced by QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(), QCacheItem::canCompress(), QRestReplyPrivate::contentCharset(), QHttpHeaderParser::firstHeaderField(), QNetworkReplyHttpImplPrivate::postRequest(), QNetworkDiskCache::prepare(), QNetworkReplyHttpImplPrivate::replyDownloadMetaData(), and QNetworkHeadersPrivate::setCookedHeader().

+ Here is the caller graph for this function:

◆ value() [2/2]

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

Definition at line 1357 of file qhttpheaders.cpp.

References d.

◆ valueAt()

QByteArrayView QHttpHeaders::valueAt ( qsizetype i) const
noexcept

Returns the header value at index i.

The index i must be valid (see \l size()).

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

Definition at line 1400 of file qhttpheaders.cpp.

References d, and i.

Referenced by QNetworkHeadersPrivate::fromHttpToRaw(), QHttpNetworkRequestPrivate::header(), and QNetworkHeadersPrivate::rawHeader().

+ Here is the caller graph for this function:

◆ values() [1/2]

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)

Definition at line 1371 of file qhttpheaders.cpp.

References d.

Referenced by QHttpHeaderParser::headerFieldValues(), QHstsHeaderParser::parse(), QAuthenticatorPrivate::parseHttpResponse(), and QHttpNetworkConnectionPrivate::parseRedirectResponse().

+ Here is the caller graph for this function:

◆ values() [2/2]

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

Definition at line 1384 of file qhttpheaders.cpp.

References d.

◆ wellKnownHeaderName()

QByteArrayView QHttpHeaders::wellKnownHeaderName ( WellKnownHeader name)
staticnoexcept

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

Definition at line 1489 of file qhttpheaders.cpp.

References headerNames, and qToUnderlying().

Referenced by QNetworkHeadersPrivate::fromHttpToRaw(), QNetworkHeadersPrivate::fromRawToHttp(), isSetCookie(), QNetworkHeadersPrivate::rawHeader(), and QNetworkHeadersPrivate::setCookedHeader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator<<

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

Writes headers into debug stream.

Definition at line 972 of file qhttpheaders.cpp.


The documentation for this class was generated from the following files: