diff options
author | Juha Vuolle <juha.vuolle@qt.io> | 2024-01-19 07:50:04 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2024-01-20 03:35:32 +0000 |
commit | fd6dc2e9e7ce12d73e095a70b3259ea649f4a62d (patch) | |
tree | 2074aac410dc8bcf2c07c623832232753aabfe36 /tests/auto/network/access | |
parent | 196594003742f0bf1c075ed5b2ec93e06f237206 (diff) |
Remove QHttpHeaders::names()
We need a way for users to consume the complete contents of
QHttpHeaders.
Until now, the only way was
for (const auto &name : h.names())
use(h.value/combinedValue(name));
which is quadratic.
Adding the usual iterators and operator[] would require us to
expose the underlying value_type, which we're not ready to do, yet.
So we added nameAt() and valueAt() functions in previous commits to
enable efficient indexed iteration without the need to expose a
value_type. Having added those, we can now remove names(), which had
the wrong value_type (QByteArrays are by definition UTF-8 in Qt, while
header names are L1), and is no longer needed to facilitate iteration.
In QNetworkRequestFactory, temporarily use toMultiMap() because we
need the combinedValue() of all headers here. The fix will be to make
QNetworkRequest QHttpHeaders-aware, but that's a Qt 6.8 thing, even
though we should still de-pessimize this code for Qt 6.7 with private
API.
Resulted from API-review.
Pick-to: 6.7
Change-Id: I65086ef4c62e22554ae7325a846bebc08b44916f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests/auto/network/access')
-rw-r--r-- | tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp | 24 |
1 files changed, 3 insertions, 21 deletions
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 |