diff options
author | Juha Vuolle <juha.vuolle@qt.io> | 2024-01-19 07:25:51 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2024-01-20 03:35:25 +0000 |
commit | 4bb12dab6a13c6deee713a77efa9ce996adc97a9 (patch) | |
tree | 45886f18e286adc4ef4cecf3315531554c07d71d /tests/auto/network/access | |
parent | a5292ad2f58252f392ad272f8c99a31c43d175a8 (diff) |
Add QHttpHeaders::valueAt() function
We need a way for users to consume the complete contents of
QHttpHeaders.
For now, the only way is
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 add valueAt() and (in a follow-up) nameAt() functions to enable
efficient indexed iteration without the need to expose a value_type.
Resulted from API-review
Pick-to: 6.7
Change-Id: I863f59618cea5682386ce26b66b4b1655eac7950
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
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 | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp b/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp index 7a7e1da0a4..77f265c9e9 100644 --- a/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp +++ b/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp @@ -186,6 +186,15 @@ void tst_QHttpHeaders::accessors() QCOMPARE(h1.size(), 5); QCOMPARE(h1.names().size(), 2); + // valueAt() + h1.clear(); + h1.append(n1, v1); + h1.append(n2, v2); + h1.append(n3, v3); + QCOMPARE(h1.valueAt(0), v1); + QCOMPARE(h1.valueAt(1), v2); + QCOMPARE(h1.valueAt(2), v3); + // removeAll() h1.clear(); QVERIFY(h1.append(n1, v1)); |