qhttpheaderparser: port some methods to QBAV

Change-Id: If9d74e42e8633cdbc0caeebedc9a36918c0b05a5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Anton Kudryavtsev 2023-08-22 15:11:41 +03:00
parent b77e1de2ba
commit 38429c16b5
2 changed files with 9 additions and 9 deletions

View File

@ -133,7 +133,7 @@ const QList<QPair<QByteArray, QByteArray> >& QHttpHeaderParser::headers() const
return fields;
}
QByteArray QHttpHeaderParser::firstHeaderField(const QByteArray &name,
QByteArray QHttpHeaderParser::firstHeaderField(QByteArrayView name,
const QByteArray &defaultValue) const
{
for (auto it = fields.constBegin(); it != fields.constEnd(); ++it) {
@ -143,7 +143,7 @@ QByteArray QHttpHeaderParser::firstHeaderField(const QByteArray &name,
return defaultValue;
}
QByteArray QHttpHeaderParser::combinedHeaderValue(const QByteArray &name, const QByteArray &defaultValue) const
QByteArray QHttpHeaderParser::combinedHeaderValue(QByteArrayView name, const QByteArray &defaultValue) const
{
const QList<QByteArray> allValues = headerFieldValues(name);
if (allValues.isEmpty())
@ -151,7 +151,7 @@ QByteArray QHttpHeaderParser::combinedHeaderValue(const QByteArray &name, const
return allValues.join(", ");
}
QList<QByteArray> QHttpHeaderParser::headerFieldValues(const QByteArray &name) const
QList<QByteArray> QHttpHeaderParser::headerFieldValues(QByteArrayView name) const
{
QList<QByteArray> result;
for (auto it = fields.constBegin(); it != fields.constEnd(); ++it)
@ -161,9 +161,9 @@ QList<QByteArray> QHttpHeaderParser::headerFieldValues(const QByteArray &name) c
return result;
}
void QHttpHeaderParser::removeHeaderField(const QByteArray &name)
void QHttpHeaderParser::removeHeaderField(QByteArrayView name)
{
auto firstEqualsName = [&name](const QPair<QByteArray, QByteArray> &header) {
auto firstEqualsName = [name](const QPair<QByteArray, QByteArray> &header) {
return name.compare(header.first, Qt::CaseInsensitive) == 0;
};
fields.removeIf(firstEqualsName);

View File

@ -62,15 +62,15 @@ public:
QString getReasonPhrase() const;
void setReasonPhrase(const QString &reason);
QByteArray firstHeaderField(const QByteArray &name,
QByteArray firstHeaderField(QByteArrayView name,
const QByteArray &defaultValue = QByteArray()) const;
QByteArray combinedHeaderValue(const QByteArray &name,
QByteArray combinedHeaderValue(QByteArrayView name,
const QByteArray &defaultValue = QByteArray()) const;
QList<QByteArray> headerFieldValues(const QByteArray &name) const;
QList<QByteArray> headerFieldValues(QByteArrayView name) const;
void setHeaderField(const QByteArray &name, const QByteArray &data);
void prependHeaderField(const QByteArray &name, const QByteArray &data);
void appendHeaderField(const QByteArray &name, const QByteArray &data);
void removeHeaderField(const QByteArray &name);
void removeHeaderField(QByteArrayView name);
void clearHeaders();
void setMaxHeaderFieldSize(qsizetype size) { maxFieldSize = size; }