![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include <qhttpheaders.h>
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 QHttpHeaders & | operator= (const QHttpHeaders &other) |
Assigns the contents of other and returns a reference to this object. | |
void | swap (QHttpHeaders &other) noexcept |
\memberswap{QHttpHeaders} | |
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< QByteArray > | values (QAnyStringView name) const |
Returns the values of header name in a list. | |
Q_NETWORK_EXPORT QList< QByteArray > | values (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, QByteArray > | toMultiMap () const |
Returns the header entries as a map from name to value(s). | |
Q_NETWORK_EXPORT QMultiHash< QByteArray, QByteArray > | toMultiHash () 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. | |
Definition at line 19 of file qhttpheaders.h.
|
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
Definition at line 23 of file qhttpheaders.h.
|
noexcept |
Creates a new QHttpHeaders object.
Definition at line 878 of file qhttpheaders.cpp.
|
default |
Disposes of the headers object.
|
default |
Creates a copy of other.
|
defaultnoexcept |
Move-constructs the object from other, which will be left \l{isEmpty()}{empty}.
bool QHttpHeaders::append | ( | QAnyStringView | name, |
QAnyStringView | value ) |
Appends a header entry with name and value and returns true
if successful.
Definition at line 1105 of file qhttpheaders.cpp.
bool QHttpHeaders::append | ( | WellKnownHeader | name, |
QAnyStringView | value ) |
Definition at line 1118 of file qhttpheaders.cpp.
void QHttpHeaders::clear | ( | ) |
Clears all header entries.
Definition at line 1501 of file qhttpheaders.cpp.
References isEmpty().
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.
Definition at line 1390 of file qhttpheaders.cpp.
QByteArray QHttpHeaders::combinedValue | ( | WellKnownHeader | name | ) | const |
Definition at line 1403 of file qhttpheaders.cpp.
bool QHttpHeaders::contains | ( | QAnyStringView | name | ) | const |
Returns whether the headers contain header with name.
Definition at line 1241 of file qhttpheaders.cpp.
References isEmpty().
bool QHttpHeaders::contains | ( | WellKnownHeader | name | ) | const |
Definition at line 1252 of file qhttpheaders.cpp.
References isEmpty().
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 888 of file qhttpheaders.cpp.
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 918 of file qhttpheaders.cpp.
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 903 of file qhttpheaders.cpp.
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.
Definition at line 1136 of file qhttpheaders.cpp.
bool QHttpHeaders::insert | ( | qsizetype | i, |
WellKnownHeader | name, | ||
QAnyStringView | value ) |
Definition at line 1150 of file qhttpheaders.cpp.
|
inlinenoexcept |
Returns true
if the headers have size 0; otherwise returns false
.
Definition at line 249 of file qhttpheaders.h.
Referenced by clear(), contains(), contains(), removeAll(), removeAll(), toListOfPairs(), toMultiHash(), toMultiMap(), value(), value(), values(), and values().
|
noexcept |
|
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}.
void QHttpHeaders::removeAll | ( | QAnyStringView | name | ) |
Removes the header name.
Definition at line 1265 of file qhttpheaders.cpp.
References isEmpty().
void QHttpHeaders::removeAll | ( | WellKnownHeader | name | ) |
Definition at line 1276 of file qhttpheaders.cpp.
References isEmpty().
Removes the header at index i.
The index i must be valid (see \l size()).
Definition at line 1291 of file qhttpheaders.cpp.
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.
Definition at line 1170 of file qhttpheaders.cpp.
bool QHttpHeaders::replace | ( | qsizetype | i, |
WellKnownHeader | name, | ||
QAnyStringView | newValue ) |
Definition at line 1184 of file qhttpheaders.cpp.
bool QHttpHeaders::replaceOrAppend | ( | QAnyStringView | name, |
QAnyStringView | newValue ) |
Definition at line 1224 of file qhttpheaders.cpp.
bool QHttpHeaders::replaceOrAppend | ( | 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.
Definition at line 1209 of file qhttpheaders.cpp.
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 1430 of file qhttpheaders.cpp.
|
noexcept |
Returns the number of header entries.
Definition at line 1416 of file qhttpheaders.cpp.
|
inlinenoexcept |
\memberswap{QHttpHeaders}
Definition at line 213 of file qhttpheaders.h.
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 1456 of file qhttpheaders.cpp.
References isEmpty().
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 1485 of file qhttpheaders.cpp.
References isEmpty().
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 1471 of file qhttpheaders.cpp.
References isEmpty().
|
noexcept |
Returns the value of the (first) header name, or defaultValue if it doesn't exist.
Definition at line 1304 of file qhttpheaders.cpp.
References isEmpty().
|
noexcept |
Definition at line 1315 of file qhttpheaders.cpp.
References isEmpty().
|
noexcept |
Returns the header value at index i.
The index i must be valid (see \l size()).
Definition at line 1358 of file qhttpheaders.cpp.
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.
Definition at line 1329 of file qhttpheaders.cpp.
References isEmpty().
QList< QByteArray > QHttpHeaders::values | ( | WellKnownHeader | name | ) | const |
Definition at line 1342 of file qhttpheaders.cpp.
References isEmpty().
|
staticnoexcept |
Returns a header name corresponding to the provided name as a view.
Definition at line 1447 of file qhttpheaders.cpp.
|
friend |
Writes headers into debug stream.
Definition at line 972 of file qhttpheaders.cpp.