diff --git a/src/base/bittorrent/tracker.cpp b/src/base/bittorrent/tracker.cpp index d52280727..e9d140dc5 100644 --- a/src/base/bittorrent/tracker.cpp +++ b/src/base/bittorrent/tracker.cpp @@ -128,7 +128,7 @@ Http::Response Tracker::processRequest(const Http::Request &request, const Http: void Tracker::respondToAnnounceRequest() { - const QMap &queryParams = m_request.query; + const QHash &queryParams = m_request.query; TrackerAnnounceRequest announceReq; // IP diff --git a/src/base/http/types.h b/src/base/http/types.h index 6bb443d6a..e89970c2c 100644 --- a/src/base/http/types.h +++ b/src/base/http/types.h @@ -98,8 +98,8 @@ namespace Http QString method; QString path; QStringMap headers; - QMap query; - QStringMap posts; + QHash query; + QHash posts; QVector files; }; diff --git a/src/webui/api/apicontroller.cpp b/src/webui/api/apicontroller.cpp index c306a351b..140ade32d 100644 --- a/src/webui/api/apicontroller.cpp +++ b/src/webui/api/apicontroller.cpp @@ -28,6 +28,8 @@ #include "apicontroller.h" +#include + #include #include @@ -45,8 +47,8 @@ QVariant APIController::run(const QString &action, const StringMap ¶ms, cons m_params = params; m_data = data; - const QString methodName {action + QLatin1String("Action")}; - if (!QMetaObject::invokeMethod(this, methodName.toLatin1().constData())) + const QByteArray methodName = action.toLatin1() + "Action"; + if (!QMetaObject::invokeMethod(this, methodName.constData())) throw APIError(APIErrorType::NotFound); return m_result; @@ -69,9 +71,13 @@ const DataMap &APIController::data() const void APIController::checkParams(const QSet &requiredParams) const { - const QSet params {this->params().keys().toSet()}; + const bool hasAllRequiredParams = std::all_of(requiredParams.cbegin(), requiredParams.cend() + , [this](const QString &requiredParam) + { + return params().contains(requiredParam); + }); - if (!params.contains(requiredParams)) + if (!hasAllRequiredParams) throw APIError(APIErrorType::BadParams); } diff --git a/src/webui/api/apicontroller.h b/src/webui/api/apicontroller.h index be620832a..0d2044efb 100644 --- a/src/webui/api/apicontroller.h +++ b/src/webui/api/apicontroller.h @@ -28,7 +28,7 @@ #pragma once -#include +#include #include #include #include @@ -36,8 +36,9 @@ class QString; struct ISessionManager; -using StringMap = QMap; -using DataMap = QMap; + +using DataMap = QHash; +using StringMap = QHash; class APIController : public QObject { diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index fc22e540e..435c5fcb1 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -123,7 +123,7 @@ private: WebSession *m_currentSession = nullptr; Http::Request m_request; Http::Environment m_env; - QMap m_params; + QHash m_params; const QString m_cacheID; const QRegularExpression m_apiPathPattern {(QLatin1String("^/api/v2/(?[A-Za-z_][A-Za-z_0-9]*)/(?[A-Za-z_][A-Za-z_0-9]*)$"))};