summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@qt.io>2024-01-05 07:17:18 +0200
committerJuha Vuolle <juha.vuolle@qt.io>2024-01-09 11:13:09 +0200
commitf5f7368cb1da675d0d57c05be2af5f6684a4c3ad (patch)
tree1e61213fe04e21550646d2ee09ca38c44ff8fd67 /examples
parent4984a8c74ce840513f67ebc656e3cd33e75574db (diff)
Make 'token' HTTP header name comparison case-insensitive
HTTP header names are case-insensitive. With the new QHttpHeaders class in use at the client-side (the colorpaletteclient app in qtdoc), the request will contain a lower-cased 'token' header => change the server-side to ignore casing Pick-to: 6.7 Task-number: QTBUG-114649 Change-Id: I69b52325017721c8d50fa3ea129802c93b2e521a Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/httpserver/colorpalette/utils.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/examples/httpserver/colorpalette/utils.h b/examples/httpserver/colorpalette/utils.h
index b24271b..02f74d4 100644
--- a/examples/httpserver/colorpalette/utils.h
+++ b/examples/httpserver/colorpalette/utils.h
@@ -57,12 +57,11 @@ static IdMap<T> tryLoadFromFile(const FromJsonFactory<T> &itemFactory, const QSt
}
static QByteArray getValueFromHeader(const QList<QPair<QByteArray, QByteArray>> &headers,
- const QString &keyToFind)
+ QByteArrayView headerName)
{
for (const auto &[key, value] : headers) {
- if (key == keyToFind) {
+ if (key.compare(headerName, Qt::CaseInsensitive) == 0)
return value;
- }
}
return QByteArray();
}
@@ -70,7 +69,7 @@ static QByteArray getValueFromHeader(const QList<QPair<QByteArray, QByteArray>>
static std::optional<QString> getTokenFromRequest(const QHttpServerRequest &request)
{
std::optional<QString> token;
- if (auto bytes = getValueFromHeader(request.headers(), "TOKEN"); !bytes.isEmpty()) {
+ if (auto bytes = getValueFromHeader(request.headers(), "token"); !bytes.isEmpty()) {
token = bytes;
}
return token;