Browse Source

Merge pull request #8515 from glassez/webapi

Fix Legacy Web API to be fully available
adaptive-webui-19844
Vladimir Golovnev 7 years ago committed by GitHub
parent
commit
9406b4b226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/webui/webapplication.cpp
  2. 2
      src/webui/webapplication.h

11
src/webui/webapplication.cpp

@ -280,7 +280,6 @@ void WebApplication::doProcessRequest() @@ -280,7 +280,6 @@ void WebApplication::doProcessRequest()
{"query/preferences", {"app", "preferences"}},
{"command/setPreferences", {"app", "setPreferences"}},
{"command/getSavePath", {"app", "defaultSavePath"}},
{"version/qbittorrent", {"app", "version"}},
{"query/getLog", {"log", "main"}},
{"query/getPeerLog", {"log", "peers"}},
@ -343,6 +342,7 @@ void WebApplication::doProcessRequest() @@ -343,6 +342,7 @@ void WebApplication::doProcessRequest()
(*params)["deleteFiles"] = "true";
const QString hash {match.captured(QLatin1String("hash"))};
if (!hash.isEmpty())
(*params)[QLatin1String("hash")] = hash;
return true;
@ -354,12 +354,17 @@ void WebApplication::doProcessRequest() @@ -354,12 +354,17 @@ void WebApplication::doProcessRequest()
APIController *controller = m_apiControllers.value(scope);
if (!controller) {
if (request().path == QLatin1String("/version/api")) {
print(QString(COMPAT_API_VERSION), Http::CONTENT_TYPE_TXT);
print(QString::number(COMPAT_API_VERSION), Http::CONTENT_TYPE_TXT);
return;
}
if (request().path == QLatin1String("/version/api_min")) {
print(QString(COMPAT_API_VERSION_MIN), Http::CONTENT_TYPE_TXT);
print(QString::number(COMPAT_API_VERSION_MIN), Http::CONTENT_TYPE_TXT);
return;
}
if (request().path == QLatin1String("/version/qbittorrent")) {
print(QString(QBT_VERSION), Http::CONTENT_TYPE_TXT);
return;
}

2
src/webui/webapplication.h

@ -126,7 +126,7 @@ private: @@ -126,7 +126,7 @@ private:
Http::Environment m_env;
const QRegularExpression m_apiPathPattern {(QLatin1String("^/api/v2/(?<scope>[A-Za-z_][A-Za-z_0-9]*)/(?<action>[A-Za-z_][A-Za-z_0-9]*)$"))};
const QRegularExpression m_apiLegacyPathPattern {QLatin1String("^/(?<action>((sync|control|query)/[A-Za-z_][A-Za-z_0-9]*|login|logout))(/(?<hash>[^/]+))?$")};
const QRegularExpression m_apiLegacyPathPattern {QLatin1String("^/(?<action>((sync|command|query)/[A-Za-z_][A-Za-z_0-9]*|login|logout))(/(?<hash>[^/]+))?$")};
QHash<QString, APIController *> m_apiControllers;
QSet<QString> m_publicAPIs;

Loading…
Cancel
Save