DRY QHttpHeaders::combinedValue() implementation
Task-number: QTBUG-122020 Change-Id: I6232ea725d47800a9236ed90b70004a915bc8b65 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit de37316160920f88101fbb59e32b401d139f2e80) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a772e31395
commit
3d6393f533
@ -790,6 +790,8 @@ public:
|
|||||||
using Self = QExplicitlySharedDataPointer<QHttpHeadersPrivate>;
|
using Self = QExplicitlySharedDataPointer<QHttpHeadersPrivate>;
|
||||||
static void removeAll(Self &d, const HeaderName &name);
|
static void removeAll(Self &d, const HeaderName &name);
|
||||||
|
|
||||||
|
void combinedValue(const HeaderName &name, QByteArray &result) const;
|
||||||
|
|
||||||
QList<Header> headers;
|
QList<Header> headers;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -819,6 +821,18 @@ void QHttpHeadersPrivate::removeAll(Self &d, const HeaderName &name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QHttpHeadersPrivate::combinedValue(const HeaderName &name, QByteArray &result) const
|
||||||
|
{
|
||||||
|
const char* separator = "";
|
||||||
|
for (const auto &h : std::as_const(headers)) {
|
||||||
|
if (h.name == name) {
|
||||||
|
result.append(separator);
|
||||||
|
result.append(h.value);
|
||||||
|
separator = ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Creates a new QHttpHeaders object.
|
Creates a new QHttpHeaders object.
|
||||||
*/
|
*/
|
||||||
@ -1365,15 +1379,7 @@ QByteArray QHttpHeaders::combinedValue(QAnyStringView name) const
|
|||||||
if (isEmpty())
|
if (isEmpty())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
const HeaderName hname(name);
|
d->combinedValue(HeaderName{name}, result);
|
||||||
const char* separator = "";
|
|
||||||
for (const auto &h : std::as_const(d->headers)) {
|
|
||||||
if (h.name == hname) {
|
|
||||||
result.append(separator);
|
|
||||||
result.append(h.value);
|
|
||||||
separator = ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1386,15 +1392,7 @@ QByteArray QHttpHeaders::combinedValue(WellKnownHeader name) const
|
|||||||
if (isEmpty())
|
if (isEmpty())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
const HeaderName hname(name);
|
d->combinedValue(HeaderName{name}, result);
|
||||||
const char* separator = "";
|
|
||||||
for (const auto &h : std::as_const(d->headers)) {
|
|
||||||
if (h.name == hname) {
|
|
||||||
result.append(separator);
|
|
||||||
result.append(h.value);
|
|
||||||
separator = ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user