![]() |
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 std::optional< qint64 > | intValue (QAnyStringView name) const noexcept |
Q_NETWORK_EXPORT std::optional< qint64 > | intValue (WellKnownHeader name) const noexcept |
Q_NETWORK_EXPORT std::optional< QList< qint64 > > | intValues (QAnyStringView name) const |
Q_NETWORK_EXPORT std::optional< QList< qint64 > > | intValues (WellKnownHeader name) const |
Q_NETWORK_EXPORT std::optional< qint64 > | intValueAt (qsizetype i) const noexcept |
Q_NETWORK_EXPORT std::optional< QDateTime > | dateTimeValue (QAnyStringView name) const |
Q_NETWORK_EXPORT std::optional< QDateTime > | dateTimeValue (WellKnownHeader name) const |
Q_NETWORK_EXPORT std::optional< QList< QDateTime > > | dateTimeValues (QAnyStringView name) const |
Q_NETWORK_EXPORT std::optional< QList< QDateTime > > | dateTimeValues (WellKnownHeader name) const |
Q_NETWORK_EXPORT std::optional< QDateTime > | dateTimeValueAt (qsizetype i) const |
Q_NETWORK_EXPORT void | setDateTimeValue (QAnyStringView name, const QDateTime &dateTime) |
Q_NETWORK_EXPORT void | setDateTimeValue (WellKnownHeader name, const QDateTime &dateTime) |
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. |
Related Symbols | |
(Note that these are not member symbols.) | |
intValues | |
setDateTimeValue | |
dateTimeValues | |
intValues | |
setDateTimeValue | |
dateTimeValues |
Definition at line 22 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 26 of file qhttpheaders.h.
|
noexcept |
Creates a new QHttpHeaders object.
Definition at line 903 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 1130 of file qhttpheaders.cpp.
bool QHttpHeaders::append | ( | WellKnownHeader | name, |
QAnyStringView | value ) |
Definition at line 1143 of file qhttpheaders.cpp.
void QHttpHeaders::clear | ( | ) |
Clears all header entries.
Definition at line 1711 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 1415 of file qhttpheaders.cpp.
QByteArray QHttpHeaders::combinedValue | ( | WellKnownHeader | name | ) | const |
Definition at line 1428 of file qhttpheaders.cpp.
bool QHttpHeaders::contains | ( | QAnyStringView | name | ) | const |
Returns whether the headers contain header with name.
Definition at line 1266 of file qhttpheaders.cpp.
References isEmpty().
bool QHttpHeaders::contains | ( | WellKnownHeader | name | ) | const |
Definition at line 1277 of file qhttpheaders.cpp.
References isEmpty().
std::optional< QDateTime > QHttpHeaders::dateTimeValue | ( | QAnyStringView | name | ) | const |
Converts the first found header value of name to a QDateTime object, following the standard HTTP date formats. If the header does not exist or contains an invalid QDateTime, returns std::nullopt
.
Definition at line 1529 of file qhttpheaders.cpp.
std::optional< QDateTime > QHttpHeaders::dateTimeValue | ( | WellKnownHeader | name | ) | const |
Definition at line 1544 of file qhttpheaders.cpp.
Converts the header value at index i to a QDateTime object following the standard HTTP date formats. The index i must be valid.
Definition at line 1615 of file qhttpheaders.cpp.
std::optional< QList< QDateTime > > QHttpHeaders::dateTimeValues | ( | QAnyStringView | name | ) | const |
Returns all the header values of name in a list of QDateTime objects, following the standard HTTP date formats. If no valid date-time values are found, returns std::nullopt
.
Definition at line 1586 of file qhttpheaders.cpp.
std::optional< QList< QDateTime > > QHttpHeaders::dateTimeValues | ( | WellKnownHeader | name | ) | const |
Definition at line 1602 of file qhttpheaders.cpp.
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 913 of file qhttpheaders.cpp.
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 943 of file qhttpheaders.cpp.
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 928 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 1161 of file qhttpheaders.cpp.
bool QHttpHeaders::insert | ( | qsizetype | i, |
WellKnownHeader | name, | ||
QAnyStringView | value ) |
Definition at line 1175 of file qhttpheaders.cpp.
|
noexcept |
Returns the value of the first valid header name interpreted as a 64-bit integer. If the header does not exist or cannot be parsed as an integer, returns std::nullopt
.
Definition at line 1448 of file qhttpheaders.cpp.
|
noexcept |
Definition at line 1464 of file qhttpheaders.cpp.
Returns the header value interpreted as 64-bit integer at index i. The index i must be valid.
Definition at line 1508 of file qhttpheaders.cpp.
std::optional< QList< qint64 > > QHttpHeaders::intValues | ( | QAnyStringView | name | ) | const |
Returns the values of the header name interpreted as 64-bit integer in a list. If the header does not exist or cannot be parsed as an integer, returns std::nullopt
.
Definition at line 1478 of file qhttpheaders.cpp.
std::optional< QList< qint64 > > QHttpHeaders::intValues | ( | WellKnownHeader | name | ) | const |
Definition at line 1495 of file qhttpheaders.cpp.
|
inlinenoexcept |
Returns true
if the headers have size 0; otherwise returns false
.
Definition at line 271 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 1290 of file qhttpheaders.cpp.
References isEmpty().
void QHttpHeaders::removeAll | ( | WellKnownHeader | name | ) |
Definition at line 1301 of file qhttpheaders.cpp.
References isEmpty().
Removes the header at index i.
The index i must be valid (see \l size()).
Definition at line 1316 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 1195 of file qhttpheaders.cpp.
bool QHttpHeaders::replace | ( | qsizetype | i, |
WellKnownHeader | name, | ||
QAnyStringView | newValue ) |
Definition at line 1209 of file qhttpheaders.cpp.
bool QHttpHeaders::replaceOrAppend | ( | QAnyStringView | name, |
QAnyStringView | newValue ) |
Definition at line 1249 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 1234 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 1640 of file qhttpheaders.cpp.
void QHttpHeaders::setDateTimeValue | ( | QAnyStringView | name, |
const QDateTime & | dateTime ) |
Sets the value of the header name name to dateTime, following the \l {https://datatracker.ietf.org/doc/html/rfc9110#name-date-time-formats}{standard HTTP IMF-fixdate format}. If the header does not exist, adds a new one.
Definition at line 1559 of file qhttpheaders.cpp.
void QHttpHeaders::setDateTimeValue | ( | WellKnownHeader | name, |
const QDateTime & | dateTime ) |
Definition at line 1572 of file qhttpheaders.cpp.
|
noexcept |
Returns the number of header entries.
Definition at line 1626 of file qhttpheaders.cpp.
|
inlinenoexcept |
\memberswap{QHttpHeaders}
Definition at line 216 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 1666 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 1695 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 1681 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 1329 of file qhttpheaders.cpp.
References isEmpty().
|
noexcept |
Definition at line 1340 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 1383 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 1354 of file qhttpheaders.cpp.
References isEmpty().
QList< QByteArray > QHttpHeaders::values | ( | WellKnownHeader | name | ) | const |
Definition at line 1367 of file qhttpheaders.cpp.
References isEmpty().
|
staticnoexcept |
Returns a header name corresponding to the provided name as a view.
Definition at line 1657 of file qhttpheaders.cpp.
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
friend |
Writes headers into debug stream.
Definition at line 997 of file qhttpheaders.cpp.
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.