summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@qt.io>2024-01-19 07:35:35 +0200
committerMarc Mutz <marc.mutz@qt.io>2024-01-20 04:35:29 +0100
commit196594003742f0bf1c075ed5b2ec93e06f237206 (patch)
tree5497e130adaa348b9652b00c650a29d1fde0fe14 /tests/auto/network/access
parent4bb12dab6a13c6deee713a77efa9ce996adc97a9 (diff)
Add QHttpHeaders::nameAt() 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 nameAt() and (in a previous commit) valueAt() functions to enable efficient indexed iteration without the need to expose a value_type. Return by QLatin1StringView, not QAnyStringView, because that statically encodes the actual encoding used (and required by HTTP specs and promised by the class documentation, so it won't need to change). For the setters, we want to be accomodating QString, QByteArray, etc, which is why those take QAnyStringView. Resulted from API-review. Pick-to: 6.7 Change-Id: I0153c5aad0f6260b5dbc963de0aaf4ef42fdd4f1 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Diffstat (limited to 'tests/auto/network/access')
-rw-r--r--tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp9
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 77f265c9e9..5f6f915420 100644
--- a/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp
+++ b/tests/auto/network/access/qhttpheaders/tst_qhttpheaders.cpp
@@ -195,6 +195,15 @@ void tst_QHttpHeaders::accessors()
QCOMPARE(h1.valueAt(1), v2);
QCOMPARE(h1.valueAt(2), v3);
+ // nameAt()
+ h1.clear();
+ h1.append(n1, v1);
+ h1.append(n2, v2);
+ h1.append(n3, v3);
+ QCOMPARE(h1.nameAt(0), n1);
+ QCOMPARE(h1.nameAt(1), n2);
+ QCOMPARE(h1.nameAt(2), n3);
+
// removeAll()
h1.clear();
QVERIFY(h1.append(n1, v1));