diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 76789a8ce..885a89618 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -801,7 +801,7 @@ void JsonApiJob::start() auto query = _additionalParams; query.addQueryItem(QLatin1String("format"), QLatin1String("json")); QUrl url = Utility::concatUrlPath(account()->url(), path(), query); - sendRequest("GET", url, _request); + sendRequest(_usePOST ? "POST" : "GET", url, _request); AbstractNetworkJob::start(); } diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h index 765204c88..e6fdbcc8c 100644 --- a/src/libsync/networkjobs.h +++ b/src/libsync/networkjobs.h @@ -373,6 +373,16 @@ public: void addQueryParams(const QUrlQuery ¶ms); void addRawHeader(const QByteArray &headerName, const QByteArray &value); + /** + * @brief usePOST - allow job to do an anonymous POST request instead of GET + * @param params: (optional) true for POST, false for GET (default). + * + * This function needs to be called before start() obviously. + */ + void usePOST(bool usePOST = true) { + _usePOST = usePOST; + } + public slots: void start() override; @@ -398,6 +408,8 @@ signals: private: QUrlQuery _additionalParams; QNetworkRequest _request; + + bool _usePOST = false; }; /**