QHttpHeaders Class | Qt Network (original) (raw)
Member Function Documentation
[noexcept]
QHttpHeaders::QHttpHeaders()
Creates a new QHttpHeaders object.
QHttpHeaders::QHttpHeaders(const QHttpHeaders &other)
Creates a copy of other.
[noexcept]
QHttpHeaders::QHttpHeaders(QHttpHeaders &&other)
Move-constructs the object from other, which will be left empty.
[noexcept]
QHttpHeaders::~QHttpHeaders()
Disposes of the headers object.
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) and Allowed field name and value characters.
bool QHttpHeaders::append(QHttpHeaders::WellKnownHeader name, QAnyStringView value)
This function overloads append(QAnyStringView, QAnyStringView).
void QHttpHeaders::clear()
Clears all header entries.
See also size().
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 HTTP RFC in that its values cannot be combined this way. Prefer values() instead.
See also values(QAnyStringView).
QByteArray QHttpHeaders::combinedValue(QHttpHeaders::WellKnownHeader name) const
This function overloads combinedValue(QAnyStringView).
bool QHttpHeaders::contains(QAnyStringView name) const
Returns whether the headers contain header with name.
See also contains(QHttpHeaders::WellKnownHeader).
bool QHttpHeaders::contains(QHttpHeaders::WellKnownHeader name) const
This function overloads has(QAnyStringView).
[static]
QHttpHeaders QHttpHeaders::fromListOfPairs(const QList<std::pair<QByteArray, QByteArray>> &headers)
Creates a new QHttpHeaders object that is populated with headers.
See also Allowed field name and value characters.
[static]
QHttpHeaders QHttpHeaders::fromMultiHash(const QMultiHash<QByteArray, QByteArray> &headers)
Creates a new QHttpHeaders object that is populated with headers.
See also Allowed field name and value characters.
[static]
QHttpHeaders QHttpHeaders::fromMultiMap(const QMultiMap<QByteArray, QByteArray> &headers)
Creates a new QHttpHeaders object that is populated with headers.
See also Allowed field name and value characters.
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 size()). Returns whether the insert succeeded.
See also append(), insert(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size(), and Allowed field name and value characters.
bool QHttpHeaders::insert(qsizetype i, QHttpHeaders::WellKnownHeader name, QAnyStringView value)
This function overloads insert(qsizetype, QAnyStringView, QAnyStringView).
[noexcept]
bool QHttpHeaders::isEmpty() const
Returns true
if the headers have size 0; otherwise returns false
.
See also size().
[noexcept]
QLatin1StringView QHttpHeaders::nameAt(qsizetype i) const
Returns the header name at index i. The index i must be valid (see size()).
Header names are case-insensitive, and the returned names are lower-cased.
See also size() and valueAt().
void QHttpHeaders::removeAll(QAnyStringView name)
Removes the header name.
See also removeAt() and removeAll(QHttpHeaders::WellKnownHeader).
void QHttpHeaders::removeAll(QHttpHeaders::WellKnownHeader name)
This function overloads removeAll(QAnyStringView).
void QHttpHeaders::removeAt(qsizetype i)
Removes the header at index i. The index i must be valid (see size()).
See also removeAll(QHttpHeaders::WellKnownHeader), removeAll(QAnyStringView), and size().
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 size()). Returns whether the replace succeeded.
See also append(), replace(qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size(), and Allowed field name and value characters.
bool QHttpHeaders::replace(qsizetype i, QHttpHeaders::WellKnownHeader name, QAnyStringView newValue)
This function overloads replace(qsizetype, QAnyStringView, QAnyStringView).
[since 6.8]
bool QHttpHeaders::replaceOrAppend(QHttpHeaders::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.
This function was introduced in Qt 6.8.
See also replaceOrAppend(QAnyStringView, QAnyStringView).
bool QHttpHeaders::replaceOrAppend(QAnyStringView name, QAnyStringView newValue)
This function overloads replaceOrAppend(WellKnownHeader, QAnyStringView).
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.
[noexcept]
qsizetype QHttpHeaders::size() const
Returns the number of header entries.
[noexcept]
void QHttpHeaders::swap(QHttpHeaders &other)
Swaps this QHttpHeaders with other. This operation is very fast and never fails.
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.
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.
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.
[noexcept]
QByteArrayView QHttpHeaders::value(QAnyStringView name, QByteArrayView defaultValue = {}) const
Returns the value of the (first) header name, or defaultValue if it doesn't exist.
See also value(QHttpHeaders::WellKnownHeader, QByteArrayView).
[noexcept]
QByteArrayView QHttpHeaders::value(QHttpHeaders::WellKnownHeader name, QByteArrayView defaultValue = {}) const
This function overloads value(QAnyStringView, QByteArrayView).
[noexcept]
QByteArrayView QHttpHeaders::valueAt(qsizetype i) const
Returns the header value at index i. The index i must be valid (see size()).
See also size(), value(), values(), combinedValue(), and nameAt().
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).
QList<QByteArray> QHttpHeaders::values(QHttpHeaders::WellKnownHeader name) const
This function overloads values(QAnyStringView).
[static noexcept]
QByteArrayView QHttpHeaders::wellKnownHeaderName(QHttpHeaders::WellKnownHeader name)
Returns a header name corresponding to the provided name as a view.
[noexcept]
QHttpHeaders &QHttpHeaders::operator=(QHttpHeaders &&other)
Move-assigns other and returns a reference to this object.
other will be left empty.
QHttpHeaders &QHttpHeaders::operator=(const QHttpHeaders &other)
Assigns the contents of other and returns a reference to this object.