diff --git a/src/network/access/qhttpheaders.cpp b/src/network/access/qhttpheaders.cpp index 1ea2890f21..7a640b509c 100644 --- a/src/network/access/qhttpheaders.cpp +++ b/src/network/access/qhttpheaders.cpp @@ -888,21 +888,6 @@ bool QHttpHeaders::contains(WellKnownHeader name) const return contains(headerNames[qToUnderlying(name)]); } -/*! - Returns a list of unique header names. - Header names are case-insensitive, and the returned - names are lower-cased. -*/ -QList QHttpHeaders::names() const -{ - QList names; - for (const Header &header: d->headers) { - if (!names.contains(header.name)) - names.append(header.name); - } - return names; -} - /*! Removes the header \a name. diff --git a/src/network/access/qhttpheaders.h b/src/network/access/qhttpheaders.h index a153d7911e..1edbd03b12 100644 --- a/src/network/access/qhttpheaders.h +++ b/src/network/access/qhttpheaders.h @@ -222,8 +222,6 @@ public: Q_NETWORK_EXPORT bool contains(QAnyStringView name) const; Q_NETWORK_EXPORT bool contains(WellKnownHeader name) const; - Q_NETWORK_EXPORT QList names() const; - Q_NETWORK_EXPORT void clear(); Q_NETWORK_EXPORT void removeAll(QAnyStringView name); Q_NETWORK_EXPORT void removeAll(WellKnownHeader name); diff --git a/src/network/access/qnetworkrequestfactory.cpp b/src/network/access/qnetworkrequestfactory.cpp index 8a1ade8f78..0941304404 100644 --- a/src/network/access/qnetworkrequestfactory.cpp +++ b/src/network/access/qnetworkrequestfactory.cpp @@ -9,6 +9,7 @@ #endif #include +#include QT_BEGIN_NAMESPACE @@ -497,7 +498,7 @@ QNetworkRequest QNetworkRequestFactoryPrivate::newRequest(const QUrl &url) const // may be multiple values per name. Note: this would not necessarily // produce right result for 'Set-Cookie' header if it has multiple values, // but since it is a purely server-side (response) header, not relevant here. - const auto headerNames = headers.names(); + const auto headerNames = headers.toMultiMap().uniqueKeys(); // ### fixme: port QNR to QHH for (const auto &name : headerNames) request.setRawHeader(name, headers.combinedValue(name)); diff --git a/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp b/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp index 5f6f915420..6a324c611d 100644 --- a/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp +++ b/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp @@ -166,26 +166,6 @@ void tst_QHttpHeaders::accessors() #undef EXISTS_N_TIMES #undef EXISTS_NOT - // names() - h1.clear(); - QVERIFY(h1.names().isEmpty()); - h1.append(n1, v1); - QCOMPARE(h1.names().size(), 1); - QCOMPARE(h1.size(), 1); - QVERIFY(h1.names().contains(n1)); - h1.append(n2, v2); - QCOMPARE(h1.names().size(), 2); - QCOMPARE(h1.size(), 2); - QVERIFY(h1.names().contains(n1)); - QVERIFY(h1.names().contains(n2)); - h1.append(n1, v1); - h1.append(n1, v1); - QCOMPARE(h1.size(), 4); - QCOMPARE(h1.names().size(), 2); - h1.append(N1, v1); // uppercase of n1 - QCOMPARE(h1.size(), 5); - QCOMPARE(h1.names().size(), 2); - // valueAt() h1.clear(); h1.append(n1, v1); @@ -353,7 +333,9 @@ void tst_QHttpHeaders::headerNameField() h1.append(u"abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&'*+-.^_`|~"_s, v1); QCOMPARE(h1.size(), 4); - QCOMPARE(h1.names().size(), 1); + QCOMPARE(h1.nameAt(0), h1.nameAt(1)); + QCOMPARE(h1.nameAt(1), h1.nameAt(2)); + QCOMPARE(h1.nameAt(2), h1.nameAt(3)); h1.clear(); // Error cases