![]() |
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 std::optional< QHttpHeaderRangeSet > | rangeValues () const |
| Q_NETWORK_EXPORT void | setRangeValues (const QHttpHeaderRangeSet &ranges) |
| 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. | |
| Q_NETWORK_EXPORT QDataStream & | operator<< (QDataStream &stream, const QHttpHeaders &headers) |
| Q_NETWORK_EXPORT QDataStream & | operator>> (QDataStream &stream, QHttpHeaders &headers) |
Related Symbols | |
(Note that these are not member symbols.) | |
| intValues | |
| setDateTimeValue | |
| dateTimeValues | |
| intValues | |
| setDateTimeValue | |
| dateTimeValues | |
Definition at line 110 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 114 of file qhttpheaders.h.
|
noexcept |
Creates a new QHttpHeaders object.
Definition at line 1280 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 1541 of file qhttpheaders.cpp.
| bool QHttpHeaders::append | ( | WellKnownHeader | name, |
| QAnyStringView | value ) |
Definition at line 1554 of file qhttpheaders.cpp.
| void QHttpHeaders::clear | ( | ) |
Clears all header entries.
Definition at line 2255 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 1827 of file qhttpheaders.cpp.
| QByteArray QHttpHeaders::combinedValue | ( | WellKnownHeader | name | ) | const |
Definition at line 1840 of file qhttpheaders.cpp.
| bool QHttpHeaders::contains | ( | QAnyStringView | name | ) | const |
Returns whether the headers contain header with name.
Definition at line 1677 of file qhttpheaders.cpp.
References headerNameMatches(), and isEmpty().
| bool QHttpHeaders::contains | ( | WellKnownHeader | name | ) | const |
Definition at line 1688 of file qhttpheaders.cpp.
References headerNameMatches(), and 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 \nullopt.
Definition at line 1941 of file qhttpheaders.cpp.
| std::optional< QDateTime > QHttpHeaders::dateTimeValue | ( | WellKnownHeader | name | ) | const |
Definition at line 1956 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 2027 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 \nullopt.
Definition at line 1998 of file qhttpheaders.cpp.
| std::optional< QList< QDateTime > > QHttpHeaders::dateTimeValues | ( | WellKnownHeader | name | ) | const |
Definition at line 2014 of file qhttpheaders.cpp.
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 1290 of file qhttpheaders.cpp.
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 1320 of file qhttpheaders.cpp.
|
static |
Creates a new QHttpHeaders object that is populated with headers.
Definition at line 1305 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 1572 of file qhttpheaders.cpp.
| bool QHttpHeaders::insert | ( | qsizetype | i, |
| WellKnownHeader | name, | ||
| QAnyStringView | value ) |
Definition at line 1586 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 \nullopt.
Definition at line 1860 of file qhttpheaders.cpp.
|
noexcept |
Definition at line 1876 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 1920 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 \nullopt.
Definition at line 1890 of file qhttpheaders.cpp.
| std::optional< QList< qint64 > > QHttpHeaders::intValues | ( | WellKnownHeader | name | ) | const |
Definition at line 1907 of file qhttpheaders.cpp.
|
inlinenoexcept |
Returns true if the headers have size 0; otherwise returns false.
Definition at line 362 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}.
| std::optional< QHttpHeaderRangeSet > QHttpHeaders::rangeValues | ( | ) | const |
Returns the ranges of the Range HTTP header fields, or \nullopt if parsing failed.
Each range represents a byte range. According to RFC 9110: \list
{start=500} and {end=std::nullopt}. {start=std::nullopt} and {end=500}, representing the last 500 bytes. {start=0} and {end=499}. \endlistThe ranges are returned in the order in which they appear in the headers.
Parsing behaves as follows: \list
Range header is present, an empty range set is returned. Range header containing a unit other than "bytes" (e.g., "seconds=1-2") is ignored. These ignored headers do not cause the parsing to fail. Range header uses the "bytes" unit but is malformed (e.g., missing the hyphen, containing invalid characters, or invalid numbers), the function returns \nullopt. \endlistDefinition at line 2067 of file qhttpheaders.cpp.
| void QHttpHeaders::removeAll | ( | QAnyStringView | name | ) |
Removes the header name.
Definition at line 1701 of file qhttpheaders.cpp.
References isEmpty().
| void QHttpHeaders::removeAll | ( | WellKnownHeader | name | ) |
Definition at line 1712 of file qhttpheaders.cpp.
References isEmpty().
Removes the header at index i.
The index i must be valid (see \l size()).
Definition at line 1727 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 1606 of file qhttpheaders.cpp.
| bool QHttpHeaders::replace | ( | qsizetype | i, |
| WellKnownHeader | name, | ||
| QAnyStringView | newValue ) |
Definition at line 1620 of file qhttpheaders.cpp.
| bool QHttpHeaders::replaceOrAppend | ( | QAnyStringView | name, |
| QAnyStringView | newValue ) |
Definition at line 1660 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 1645 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 2184 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 1971 of file qhttpheaders.cpp.
| void QHttpHeaders::setDateTimeValue | ( | WellKnownHeader | name, |
| const QDateTime & | dateTime ) |
Definition at line 1984 of file qhttpheaders.cpp.
| void QHttpHeaders::setRangeValues | ( | const QHttpHeaderRangeSet & | ranges | ) |
Sets the Range HTTP header field to the specified list of ranges.
The ranges are formatted using the "bytes" unit, in the order in which ranges holds them. For each QHttpHeaderRangeSpec: \list
"500-". "-500", representing the last 500 bytes. "0-499". \endlistIf multiple ranges are provided, they will be joined by commas, for example: "bytes=0-499, 1000-".
If ranges is empty, the Range header is removed.
Definition at line 2142 of file qhttpheaders.cpp.
|
noexcept |
Returns the number of header entries.
Definition at line 2170 of file qhttpheaders.cpp.
|
inlinenoexcept |
\memberswap{QHttpHeaders}
Definition at line 304 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 2210 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 2239 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 2225 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 1740 of file qhttpheaders.cpp.
References isEmpty().
|
noexcept |
Definition at line 1751 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 1794 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 1765 of file qhttpheaders.cpp.
References isEmpty().
| QList< QByteArray > QHttpHeaders::values | ( | WellKnownHeader | name | ) | const |
Definition at line 1778 of file qhttpheaders.cpp.
References isEmpty().
|
staticnoexcept |
Returns a header name corresponding to the provided name as a view.
Definition at line 2201 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 |
|
friend |
Writes headers into debug stream.
Definition at line 1374 of file qhttpheaders.cpp.
|
friend |
Reads headers from stream in into headers.
Definition at line 1418 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.