mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
JsonApiJob: Add method usePOST to allow anonymous POST requests
Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
parent
2039872ee5
commit
9447a10716
2 changed files with 13 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue